Class: ApiClientBulkLoader::Client::PolymorphicAssociationAdapter
- Inherits:
-
BulkLoadAdapter
- Object
- BulkLoadAdapter
- ApiClientBulkLoader::Client::PolymorphicAssociationAdapter
- Defined in:
- lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb
Overview
Adapts into the bulk loader. Mainly useful for storing the details of the bulk call.
Instance Attribute Summary collapse
-
#resource_translation ⇒ Object
readonly
Returns the value of attribute resource_translation.
-
#type_from ⇒ Object
readonly
Returns the value of attribute type_from.
Attributes inherited from BulkLoadAdapter
#attribute, #autoload, #limit, #values_from
Instance Method Summary collapse
-
#fetch(values, resource_type) ⇒ Object
Fetch.
-
#initialize(resource_translation, attribute = nil, type_from = nil, values_from = nil, autoload = true, is_has_one = false, limit = nil) ⇒ PolymorphicAssociationAdapter
constructor
A new instance of PolymorphicAssociationAdapter.
-
#push(values, resource_type) ⇒ Object
Push.
Methods inherited from BulkLoadAdapter
Constructor Details
#initialize(resource_translation, attribute = nil, type_from = nil, values_from = nil, autoload = true, is_has_one = false, limit = nil) ⇒ PolymorphicAssociationAdapter
Returns a new instance of PolymorphicAssociationAdapter.
7 8 9 10 11 |
# File 'lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb', line 7 def initialize(resource_translation, attribute = nil, type_from = nil, values_from = nil, autoload = true, is_has_one = false, limit = nil) @resource_translation = resource_translation @type_from = type_from super(attribute, values_from, autoload, is_has_one, limit) end |
Instance Attribute Details
#resource_translation ⇒ Object (readonly)
Returns the value of attribute resource_translation.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb', line 5 def resource_translation @resource_translation end |
#type_from ⇒ Object (readonly)
Returns the value of attribute type_from.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb', line 5 def type_from @type_from end |
Instance Method Details
#fetch(values, resource_type) ⇒ Object
Fetch.
14 15 16 17 |
# File 'lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb', line 14 def fetch(values, resource_type) results = bulk_loader.fetch(@resource_translation[resource_type], values, @attribute) return @has_one ? results.first : results end |
#push(values, resource_type) ⇒ Object
Push.
20 21 22 |
# File 'lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb', line 20 def push(values, resource_type) bulk_loader.push(@resource_translation[resource_type], values, @attribute) end |