Class: SpreeCmCommissioner::Transit::SeatSelection
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Transit::SeatSelection
- Defined in:
- lib/spree_cm_commissioner/transit/seat_selection.rb
Instance Attribute Summary collapse
-
#block_ids ⇒ Object
Returns the value of attribute block_ids.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#variant_id ⇒ Object
Returns the value of attribute variant_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SeatSelection
constructor
A new instance of SeatSelection.
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SeatSelection
Returns a new instance of SeatSelection.
5 6 7 8 9 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 5 def initialize( = {}) @variant_id = [:variant_id] @quantity = [:quantity]&.to_i @block_ids = [:block_ids] || [] end |
Instance Attribute Details
#block_ids ⇒ Object
Returns the value of attribute block_ids.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 3 def block_ids @block_ids end |
#quantity ⇒ Object
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 3 def quantity @quantity end |
#variant_id ⇒ Object
Returns the value of attribute variant_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 3 def variant_id @variant_id end |
Class Method Details
.from_hash(hash) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 11 def self.from_hash(hash) new( variant_id: hash[:variant_id], quantity: hash[:quantity], block_ids: hash[:block_ids] || [] # empty when no seat selection. ) end |
Instance Method Details
#to_h ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/spree_cm_commissioner/transit/seat_selection.rb', line 19 def to_h { variant_id: @variant_id, quantity: @quantity, block_ids: @block_ids } end |