Module: Fera::HasManyOrders
- Extended by:
- ActiveSupport::Concern
- Included in:
- Customer
- Defined in:
- lib/fera/models/concerns/has_many_orders.rb
Instance Method Summary collapse
Instance Method Details
#orders=(new_orders) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fera/models/concerns/has_many_orders.rb', line 11 def orders=(new_orders) @orders = new_orders.to_a.map do |model| if model.is_a?(Order) model else model_id = model.try(:with_indifferent_access).try(:[], :id) Order.new(model, model_id.present?) end end end |
#photos(query = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fera/models/concerns/has_many_orders.rb', line 22 def photos(query = {}) if @orders && query.blank? @orders.to_a else Order.where(query.merge("#{ self.class.name.demodulize.underscore }_id" => id)) end end |