Module: Fera::BelongsToOrder
- Extended by:
- ActiveSupport::Concern
- Included in:
- Media, Review, Submission
- Defined in:
- lib/fera/models/concerns/belongs_to_order.rb
Instance Method Summary collapse
- #external_order_id=(new_id) ⇒ Object
- #order ⇒ Object
- #order=(order) ⇒ Object
- #order_id=(new_id) ⇒ Object
- #reload ⇒ Object
Instance Method Details
#external_order_id=(new_id) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/fera/models/concerns/belongs_to_order.rb', line 42 def external_order_id=(new_id) return if external_order_id == new_id if new_id.nil? reset_order_instance_assoc else self.attributes['external_order_id'] = new_id end end |
#order ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/fera/models/concerns/belongs_to_order.rb', line 52 def order if @order.present? @order else load_order end end |
#order=(order) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fera/models/concerns/belongs_to_order.rb', line 11 def order=(order) order_id = if order.is_a?(Order) order.id else order.try(:with_indifferent_access).try(:[], :id) end external_order_id = if order.is_a?(Order) order.external_id else order.try(:with_indifferent_access).try(:[], :external_id) end @order = if order.is_a?(Order) order else Order.new(order, order_id.present?) end self.attributes['order_id'] = order_id self.attributes['external_order_id'] = external_order_id self.attributes.delete('order') end |
#order_id=(new_id) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/fera/models/concerns/belongs_to_order.rb', line 32 def order_id=(new_id) return if order_id == new_id if new_id.nil? reset_order_instance_assoc else self.attributes['order_id'] = new_id end end |
#reload ⇒ Object
60 61 62 63 |
# File 'lib/fera/models/concerns/belongs_to_order.rb', line 60 def reload reset_order_instance_assoc super end |