Class: AbstractImporter::Collection
- Inherits:
-
Struct
- Object
- Struct
- AbstractImporter::Collection
- Defined in:
- lib/abstract_importer/collection.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
Instance Method Summary collapse
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model
2 3 4 |
# File 'lib/abstract_importer/collection.rb', line 2 def model @model end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/abstract_importer/collection.rb', line 2 def name @name end |
#options ⇒ Object
Returns the value of attribute options
2 3 4 |
# File 'lib/abstract_importer/collection.rb', line 2 def @options end |
#scope ⇒ Object
Returns the value of attribute scope
2 3 4 |
# File 'lib/abstract_importer/collection.rb', line 2 def scope @scope end |
#table_name ⇒ Object
Returns the value of attribute table_name
2 3 4 |
# File 'lib/abstract_importer/collection.rb', line 2 def table_name @table_name end |
Instance Method Details
#association_attrs ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/abstract_importer/collection.rb', line 4 def association_attrs return @assocation_attrs if defined?(@assocation_attrs) # Instead of calling `tenant.people.build(__)`, we'll reflect on the # association to find its foreign key and its owner's id, so that we # can call `Person.new(__.merge(tenant_id: id))`. @assocation_attrs = {} assocation = scope.instance_variable_get(:@association) unless assocation.is_a?(ActiveRecord::Associations::HasManyThroughAssociation) @assocation_attrs.merge!(assocation.reflection.foreign_key.to_sym => assocation.owner.id) end @assocation_attrs.freeze end |