Class: Warb::Components::CopyCodeButton

Inherits:
Button show all
Defined in:
lib/warb/components/copy_code_button.rb

Constant Summary collapse

BUTTON_TYPE =
'copy_code'

Instance Attribute Summary collapse

Attributes inherited from Button

#index, #sub_type

Instance Method Summary collapse

Methods inherited from Button

#initialize

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Warb::Components::Button

Instance Attribute Details

#coupon_codeObject

Returns the value of attribute coupon_code.



8
9
10
# File 'lib/warb/components/copy_code_button.rb', line 8

def coupon_code
  @coupon_code
end

Instance Method Details

#to_hObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/warb/components/copy_code_button.rb', line 10

def to_h
  button_payload = super

  if coupon_code || @params[:coupon_code]
    button_payload[:parameters] = Array.new(1, {
                                              type: 'coupon_code',
                                              coupon_code: coupon_code || @params[:coupon_code]
                                            })
  end

  button_payload
end