Class: Datamappify::Data::Criteria::ActiveRecord::FindMultiple
- Inherits:
-
Relational::FindMultiple
- Object
- Common
- Relational::FindMultiple
- Datamappify::Data::Criteria::ActiveRecord::FindMultiple
- Defined in:
- lib/datamappify/data/criteria/active_record/find_multiple.rb
Instance Attribute Summary
Attributes inherited from Relational::FindMultiple
Attributes inherited from Common
#attributes, #attributes_and_values, #criteria, #entity, #options, #source_class
Instance Method Summary collapse
- #records ⇒ Array private
- #structured_criteria(primaries, secondaries) ⇒ Hash private
Methods inherited from Relational::FindMultiple
#data_record_for, #initialize, #perform, #record_value_for, #update_entity, #updated_attributes
Methods inherited from Common
#any_attribute, #default_source_class_name, #ignore?, #ignore_attribute?, #initialize, #key_name, #key_value, #new_record?, #perform_with_callbacks, #pk, #primary_record?, #store_attribute_value
Constructor Details
This class inherits a constructor from Datamappify::Data::Criteria::Relational::FindMultiple
Instance Method Details
#records ⇒ Array (private)
11 12 13 14 15 |
# File 'lib/datamappify/data/criteria/active_record/find_multiple.rb', line 11 def records source_class.joins(@secondaries.map(&:source_key)).where( structured_criteria(primaries, secondaries) ) end |
#structured_criteria(primaries, secondaries) ⇒ Hash (private)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/datamappify/data/criteria/active_record/find_multiple.rb', line 22 def structured_criteria(primaries, secondaries) _criteria = {} primaries.each do |primary| _criteria[primary.source_attribute_key] = primary.value end secondaries.each do |secondary| _criteria[secondary.source_table] ||= {} _criteria[secondary.source_table][secondary.source_attribute_key] = secondary.value end _criteria end |