Module: Sequencescape::Api::Associations::HasMany

Defined in:
lib/sequencescape-api/associations/has_many.rb

Defined Under Namespace

Modules: Json, Validation Classes: AssociationProxy, InlineAssociationProxy

Instance Method Summary collapse

Instance Method Details

#has_many(association, options = {}, &block) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/sequencescape-api/associations/has_many.rb', line 83

def has_many(association, options = {}, &block)
  association = association.to_sym

  proxy = Class.new(
    case options[:disposition].try(:to_sym)
    when :inline then InlineAssociationProxy
    else AssociationProxy
    end
  )
  proxy.association = association
  proxy.options     = options
  proxy.instance_eval(&block) if block_given?

  association_methods(association, :has_many, proxy)
end