Class: Seedie::Associations::BelongsTo
- Inherits:
-
BaseAssociation
- Object
- BaseAssociation
- Seedie::Associations::BelongsTo
- Defined in:
- lib/seedie/associations/belongs_to.rb
Constant Summary
Constants inherited from BaseAssociation
Seedie::Associations::BaseAssociation::DEFAULT_COUNT, Seedie::Associations::BaseAssociation::INDEX
Instance Attribute Summary collapse
-
#associated_field_set ⇒ Object
readonly
Returns the value of attribute associated_field_set.
Attributes inherited from BaseAssociation
#association_config, #model, #record, #reporters
Instance Method Summary collapse
- #generate_association(klass, config, index) ⇒ Object
- #generate_associations ⇒ Object
-
#initialize(model, association_config, reporters = []) ⇒ BelongsTo
constructor
A new instance of BelongsTo.
Methods included from Reporters::Reportable
Constructor Details
#initialize(model, association_config, reporters = []) ⇒ BelongsTo
Returns a new instance of BelongsTo.
8 9 10 11 12 |
# File 'lib/seedie/associations/belongs_to.rb', line 8 def initialize(model, association_config, reporters = []) super(nil, model, association_config, reporters) @associated_field_set = {} end |
Instance Attribute Details
#associated_field_set ⇒ Object (readonly)
Returns the value of attribute associated_field_set.
6 7 8 |
# File 'lib/seedie/associations/belongs_to.rb', line 6 def associated_field_set @associated_field_set end |
Instance Method Details
#generate_association(klass, config, index) ⇒ Object
26 27 28 29 30 |
# File 'lib/seedie/associations/belongs_to.rb', line 26 def generate_association(klass, config, index) field_values_set = FieldValuesSet.new(klass, config, index).generate_field_values Model::Creator.new(klass).create!(field_values_set) end |
#generate_associations ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/seedie/associations/belongs_to.rb', line 14 def generate_associations return if association_config["belongs_to"].nil? report(:belongs_to_start) association_config["belongs_to"].each do |association_name, association_config| reflection = model.reflect_on_association(association_name) handle_association_config_type(reflection, association_name, association_config) end end |