Class: Locomotive::Steam::ContentEntryRepository::Conditions
- Inherits:
-
Object
- Object
- Locomotive::Steam::ContentEntryRepository::Conditions
- Defined in:
- lib/locomotive/steam/repositories/content_entry_repository.rb
Instance Method Summary collapse
-
#initialize(conditions = {}, fields, target_repository) ⇒ Conditions
constructor
A new instance of Conditions.
- #prepare ⇒ Object
Constructor Details
#initialize(conditions = {}, fields, target_repository) ⇒ Conditions
Returns a new instance of Conditions.
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/locomotive/steam/repositories/content_entry_repository.rb', line 204 def initialize(conditions = {}, fields, target_repository) @conditions = conditions.try(:with_indifferent_access) || {} @fields, @operators = fields, {} @target_repository = target_repository @conditions.each do |name, value| _name, operator = name.to_s.split('.') @operators[_name] = operator if operator end end |
Instance Method Details
#prepare ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/locomotive/steam/repositories/content_entry_repository.rb', line 215 def prepare # selects _prepare(@fields.selects) do |field, value| field..by_name(value).try(:_id) end # date _prepare(@fields.dates_and_date_times) { |field, value| value_to_date(value, field.type) } # belongs_to _prepare(@fields.belongs_to) { |field, value| value_to_id(value, field.target_id) } # many_to_many _prepare(@fields.many_to_many) { |field, value| values_to_ids(value, field.target_id) } @conditions end |