Module: SpreeCmCommissioner::OptionTypeAttrType
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb
Constant Summary collapse
- ATTRIBUTE_TYPES =
%w[ float integer string boolean array date time color coordinate state_selection payment_option delivery_option ].freeze
- RESERVED_OPTIONS =
{ 'location' => 'state_selection', 'start-date' => 'date', 'end-date' => 'date', 'start-time' => 'time', 'end-time' => 'time', 'reminder-in-hours' => 'integer', 'duration-in-hours' => 'integer', 'duration-in-minutes' => 'integer', 'duration-in-seconds' => 'integer', 'payment-option' => 'payment_option', 'delivery-option' => 'delivery_option', 'max-quantity-per-order' => 'integer', 'due-date' => 'integer', 'month' => 'integer', 'number-of-adults' => 'integer', 'number-of-kids' => 'integer', 'kids-age-max' => 'integer', 'allowed-extra-adults' => 'integer', 'allowed-extra-kids' => 'integer', 'bib-prefix' => 'string', 'bib-zerofill' => 'integer', 'bib-display-prefix' => 'boolean', 'bib-pre-generation-on-create' => 'boolean', 'seat-number-positions' => 'array', 'color' => 'color', 'ticket-type' => 'string', 'seat-type' => 'string', 'intercity-taxi' => 'string' }.freeze
Instance Method Summary collapse
- #reserved_option? ⇒ Boolean
- #set_reverved_options_attributes ⇒ Object
- #sort_date_time_option_values ⇒ Object
- #ticket_type? ⇒ Boolean
- #update_variants_metadata ⇒ Object
Instance Method Details
#reserved_option? ⇒ Boolean
71 72 73 74 75 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 71 def reserved_option? return name_was.in?(RESERVED_OPTIONS.keys) if name_changed? name.in?(RESERVED_OPTIONS.keys) end |
#set_reverved_options_attributes ⇒ Object
81 82 83 84 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 81 def self.attr_type = RESERVED_OPTIONS[name] self.kind = :variant end |
#sort_date_time_option_values ⇒ Object
86 87 88 89 90 91 92 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 86 def sort_date_time_option_values ordered_option_values = option_values.sort_by { |value| Time.zone.parse(value.name) }.reverse ordered_option_values.each_with_index do |value, index| position = index + 1 value.update(position: position) end end |
#ticket_type? ⇒ Boolean
77 78 79 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 77 def ticket_type? name == 'ticket-type' end |
#update_variants_metadata ⇒ Object
94 95 96 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 94 def SpreeCmCommissioner::OptionTypeVariantsPublicMetadataUpdaterJob.perform_later(id) end |