module Disposable::Twin::Property::Hash

trailblazer.to/gems/disposable/api.html#hash

Public Class Methods

included(includer) click to toggle source
# File lib/disposable/twin/property/hash.rb, line 7
def self.included(includer)
  # hash: true top-level properties need :default support.
  includer.feature Default

  # Recursively include Struct in :hash and nested properties.
  # defaults is applied to all ::property calls.
  includer.defaults do |name, options|
    if options[:field] == :hash
      hash_options
    else
      {}
    end
  end
end

Private Class Methods

hash_options() click to toggle source

Note that :_features ‘include`s modules in this order, first to last.

# File lib/disposable/twin/property/hash.rb, line 24
def self.hash_options
  { _features: [NestedDefaults, Property::Struct, Hash::Sync], default: ->(*) { ::Hash.new } }
end