Class: Lightrail::Wrapper::Associations::HasManyConfig

Inherits:
AssociationConfig show all
Defined in:
lib/lightrail/wrapper/associations.rb

Instance Attribute Summary

Attributes inherited from AssociationConfig

#as, #includes, #key, #name

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ HasManyConfig

Returns a new instance of HasManyConfig.



36
37
38
39
40
41
# File 'lib/lightrail/wrapper/associations.rb', line 36

def initialize(name, options)
  super
  @as          = options[:as] || name.to_sym
  @key         = options[:key] || name.to_sym
  @includes    = options[:includes] || name.to_s
end

Instance Method Details

#update(view, object) ⇒ Object



43
44
45
# File 'lib/lightrail/wrapper/associations.rb', line 43

def update(view, object)
  view[@key] = object.map(&:id)
end