Module: Disposable::Twin::Composition

Defined in:
lib/disposable/twin/composition.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



33
34
35
36
# File 'lib/disposable/twin/composition.rb', line 33

def self.included(base)
  base.send(:include, Expose::Initialize)
  base.extend(ClassMethods)
end

Instance Method Details

#to_nested_hashObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/disposable/twin/composition.rb', line 38

def to_nested_hash(*)
  hash = {}

  @model.each do |name, model| # TODO: provide list of composee attributes in Composition.
    part_properties = schema.find_all { |dfn| dfn[:on] == name }.collect{ |dfn| dfn[:name].to_sym }
    hash[name] = self.class.nested_hash_representer.new(self).to_hash(include: part_properties)
  end

  hash
end