Class: Lightrail::Wrapper::Associations::HasOneConfig
- Inherits:
-
AssociationConfig
- Object
- AssociationConfig
- Lightrail::Wrapper::Associations::HasOneConfig
- Defined in:
- lib/lightrail/wrapper/associations.rb
Instance Attribute Summary
Attributes inherited from AssociationConfig
Instance Method Summary collapse
-
#initialize(name, options) ⇒ HasOneConfig
constructor
A new instance of HasOneConfig.
- #update(view, object) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ HasOneConfig
Returns a new instance of HasOneConfig.
23 24 25 26 27 28 |
# File 'lib/lightrail/wrapper/associations.rb', line 23 def initialize(name, ) super @as = [:as] || name.to_s.pluralize.to_sym @key = [:key] || :"#{name}_id" @includes = [: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 |