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', 'vote-package' => 'integer' }.freeze
Instance Method Summary collapse
- #reserved_option? ⇒ Boolean
- #set_reserved_options_attributes ⇒ Object
- #sort_date_time_option_values ⇒ Object
- #ticket_type? ⇒ Boolean
- #update_variants_metadata ⇒ Object
Instance Method Details
#reserved_option? ⇒ Boolean
83 84 85 86 87 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 83 def reserved_option? return name_was.in?(RESERVED_OPTIONS.keys) if name_changed? name.in?(RESERVED_OPTIONS.keys) end |
#set_reserved_options_attributes ⇒ Object
93 94 95 96 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 93 def self.attr_type = RESERVED_OPTIONS[name] self.kind = :variant end |
#sort_date_time_option_values ⇒ Object
98 99 100 101 102 103 104 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 98 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
89 90 91 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 89 def ticket_type? name == 'ticket-type' end |
#update_variants_metadata ⇒ Object
106 107 108 |
# File 'app/models/concerns/spree_cm_commissioner/option_type_attr_type.rb', line 106 def SpreeCmCommissioner::OptionTypeVariantsPublicMetadataUpdaterJob.perform_later(option_type_id: id) end |