Class: Cocooned::AssociationBuilder
- Inherits:
-
Object
- Object
- Cocooned::AssociationBuilder
- Defined in:
- lib/cocooned/association_builder.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
-
#form ⇒ Object
Returns the value of attribute form.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #build_object ⇒ Object
-
#initialize(form, association, options = {}) ⇒ AssociationBuilder
constructor
A new instance of AssociationBuilder.
- #plural_name ⇒ Object
- #singular_name ⇒ Object
Constructor Details
#initialize(form, association, options = {}) ⇒ AssociationBuilder
Returns a new instance of AssociationBuilder.
7 8 9 10 11 |
# File 'lib/cocooned/association_builder.rb', line 7 def initialize(form, association, = {}) self.form = form self.association = association self. = .reverse_merge(force_non_association_create: false, wrap_object: false) end |
Instance Attribute Details
#association ⇒ Object
Returns the value of attribute association.
5 6 7 |
# File 'lib/cocooned/association_builder.rb', line 5 def association @association end |
#form ⇒ Object
Returns the value of attribute form.
5 6 7 |
# File 'lib/cocooned/association_builder.rb', line 5 def form @form end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/cocooned/association_builder.rb', line 5 def end |
Instance Method Details
#build_object ⇒ Object
13 14 15 16 17 |
# File 'lib/cocooned/association_builder.rb', line 13 def build_object model = reflection ? build_with_reflection : build_without_reflection model = [:wrap_object].call(model) if [:wrap_object].respond_to?(:call) model end |
#plural_name ⇒ Object
23 24 25 |
# File 'lib/cocooned/association_builder.rb', line 23 def plural_name association.to_s.pluralize end |
#singular_name ⇒ Object
19 20 21 |
# File 'lib/cocooned/association_builder.rb', line 19 def singular_name association.to_s.singularize end |