Class: Lightrail::Wrapper::Associations::HasOneConfig
Instance Attribute Summary
#as, #includes, #key, #name
Instance Method Summary
collapse
Constructor Details
#initialize(name, options) ⇒ HasOneConfig
23
24
25
26
27
28
|
# File 'lib/lightrail/wrapper/associations.rb', line 23
def initialize(name, options)
super
@as = options[:as] || name.to_s.pluralize.to_sym
@key = options[:key] || :"#{name}_id"
@includes = options[:includes] || name.to_s.pluralize
end
|
Instance Method Details
#update(view, object) ⇒ Object
30
31
32
|
# File 'lib/lightrail/wrapper/associations.rb', line 30
def update(view, object)
view[@key] = object && object.id
end
|