Module: Sequencescape::Api::Composition

Included in:
Resource
Defined in:
lib/sequencescape-api/composition.rb

Defined Under Namespace

Modules: Target

Instance Method Summary (collapse)

Instance Method Details

- (Object) composed_of(name, options = {})



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sequencescape-api/composition.rb', line 24

def composed_of(name, options = {})
  composed_class_name = options[:class_name] || name

  line = __LINE__ + 1
  class_eval(%Q{
    def #{name}
      api.model(#{composed_class_name.inspect}).new(self, attributes_for(#{name.to_s.inspect}))
    end

    def #{name}=(attributes)
      @attributes[#{name.to_s.inspect}] = attributes
    end
  }, __FILE__, line)
end