Module: Playbook::Order

Included in:
KitBase
Defined in:
lib/playbook/order.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/playbook/order.rb', line 5

def self.included(base)
  base.prop :order
end

Instance Method Details

#order_optionsObject

rubocop:enable Style/IfInsideElse



27
28
29
30
31
# File 'lib/playbook/order.rb', line 27

def order_options
  {
    order: "order",
  }
end

#order_propsObject

rubocop:disable Style/IfInsideElse



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/playbook/order.rb', line 10

def order_props
  selected_props = order_options.keys.select { |sk| try(sk) }
  return nil unless selected_props.present?

  selected_props.map do |k|
    order_value = send(k)
    if order_value.is_a?(Hash)
      order_value.map do |media_size, order_size_value|
        "flex_order_#{media_size}_#{order_size_value}" if order_values.include? order_size_value.to_s
      end
    else
      "flex_order_#{order_value}" if order_values.include? order_value.to_s
    end
  end.compact.join(" ")
end

#order_valuesObject



33
34
35
# File 'lib/playbook/order.rb', line 33

def order_values
  %w[1 2 3 4 5 6 7 8 9 10 11 12]
end