Class: QuickTravel::PriceChanges::PriceChange
- Inherits:
-
Object
- Object
- QuickTravel::PriceChanges::PriceChange
- Defined in:
- lib/quick_travel/price_changes/price_change.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#changed_price ⇒ Object
readonly
Returns the value of attribute changed_price.
-
#original_price ⇒ Object
readonly
Returns the value of attribute original_price.
-
#price_change ⇒ Object
readonly
Returns the value of attribute price_change.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#reasons ⇒ Object
readonly
Returns the value of attribute reasons.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #applied_on?(id, type = 'Reservation') ⇒ Boolean
-
#initialize(attrs = {}) ⇒ PriceChange
constructor
A new instance of PriceChange.
Constructor Details
#initialize(attrs = {}) ⇒ PriceChange
Returns a new instance of PriceChange.
9 10 11 12 13 14 15 16 17 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 9 def initialize(attrs = {}) @target = OpenStruct.new(attrs.fetch('target').slice('id', 'type')) @original_price = Money.new(attrs.fetch('original_price_in_cents')) @changed_price = Money.new(attrs.fetch('changed_price_in_cents')) @price_change = Money.new(attrs.fetch('price_change_in_cents')) @reason = attrs.fetch('reason') @reasons = attrs.fetch('reasons', [@reason]) end |
Instance Attribute Details
#changed_price ⇒ Object (readonly)
Returns the value of attribute changed_price.
5 6 7 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 5 def changed_price @changed_price end |
#original_price ⇒ Object (readonly)
Returns the value of attribute original_price.
5 6 7 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 5 def original_price @original_price end |
#price_change ⇒ Object (readonly)
Returns the value of attribute price_change.
5 6 7 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 5 def price_change @price_change end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
5 6 7 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 5 def reason @reason end |
#reasons ⇒ Object (readonly)
Returns the value of attribute reasons.
5 6 7 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 5 def reasons @reasons end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 4 def target @target end |
Instance Method Details
#applied_on?(id, type = 'Reservation') ⇒ Boolean
19 20 21 |
# File 'lib/quick_travel/price_changes/price_change.rb', line 19 def applied_on?(id, type = 'Reservation') @target.type == type && @target.id == id end |