module Wardrobe::InstanceMethods
Public Class Methods
new(**hash)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 5 def initialize(**hash) # raise "POC: More than one arg not supported..." if args.length > 1 # kargs = args.first.merge(kargs) if args.any? _initialize { _wardrobe_init(hash) } end
Public Instance Methods
_add_attribute(name, klass, **args, &blk)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 19 def _add_attribute(name, klass, **args, &blk) @_wardrobe_set_singleton = _attribute_store.add( name, klass, self.class, self.class.wardrobe_stores, **args, &blk ) end
_attribute_store()
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 15 def _attribute_store _attribute_store_singleton || self.class.attribute_store end
_get_attribute_value(atr)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 29 def _get_attribute_value(atr) instance_variable_get(atr.ivar_name) end
_initializing?()
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 11 def _initializing? instance_variable_defined?(:@_initializing) && @_initializing end
_set_attribute_value(atr, value)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 25 def _set_attribute_value(atr, value) instance_variable_set(atr.ivar_name, value) end
Private Instance Methods
_attribute_init(atr, hash, name)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 52 def _attribute_init(atr, hash, name) send(atr.setter_name, hash[name]) end
_attribute_store_singleton()
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 41 def _attribute_store_singleton @_wardrobe_set_singleton if instance_variable_defined?('@_wardrobe_set_singleton') end
_initialize() { || ... }
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 35 def _initialize instance_variable_set(:@_initializing, true) yield remove_instance_variable(:@_initializing) end
_wardrobe_init(data)
click to toggle source
# File lib/wardrobe/instance_methods.rb, line 45 def _wardrobe_init(data) # Should we also loop over the hash and report on missing or additional attributes? _attribute_store.each do |name, atr| _attribute_init(atr, data, name) end end