Class: ApiClientBulkLoader::Client::AssociationAdapter
- Inherits:
-
Object
- Object
- ApiClientBulkLoader::Client::AssociationAdapter
- Defined in:
- lib/api_client_bulk_loader/client/association_adapter.rb
Overview
Adapts into the bulk loader. Mainly useful for storing the details of the bulk call.
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#autoload ⇒ Object
readonly
Returns the value of attribute autoload.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#resource_model ⇒ Object
readonly
Returns the value of attribute resource_model.
-
#values_from ⇒ Object
readonly
Returns the value of attribute values_from.
Instance Method Summary collapse
-
#fetch(values) ⇒ Object
Fetch.
-
#initialize(res_model, attribute = nil, values_from = nil, autoload = false, is_has_one = false, limit = nil) ⇒ AssociationAdapter
constructor
A new instance of AssociationAdapter.
-
#push(values) ⇒ Object
Push.
Constructor Details
#initialize(res_model, attribute = nil, values_from = nil, autoload = false, is_has_one = false, limit = nil) ⇒ AssociationAdapter
Returns a new instance of AssociationAdapter.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 7 def initialize(res_model, attribute = nil, values_from = nil, autoload = false, is_has_one = false, limit = nil) @resource_model = res_model @attribute = attribute @autoload = autoload @values_from = values_from @has_one = is_has_one @limit = limit RequestStore.store[:bulk_loader] ||= ApiClientBulkLoader::Client::Loader.new @bulk_loader = RequestStore.store[:bulk_loader] end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 5 def attribute @attribute end |
#autoload ⇒ Object (readonly)
Returns the value of attribute autoload.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 5 def autoload @autoload end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 5 def limit @limit end |
#resource_model ⇒ Object (readonly)
Returns the value of attribute resource_model.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 5 def resource_model @resource_model end |
#values_from ⇒ Object (readonly)
Returns the value of attribute values_from.
5 6 7 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 5 def values_from @values_from end |
Instance Method Details
#fetch(values) ⇒ Object
Fetch.
20 21 22 23 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 20 def fetch(values) results = @bulk_loader.fetch(@resource_model, values, @attribute) return @has_one ? results.first : results end |
#push(values) ⇒ Object
Push.
26 27 28 |
# File 'lib/api_client_bulk_loader/client/association_adapter.rb', line 26 def push(values) @bulk_loader.push(@resource_model, values, @attribute) end |