Class: Locomotive::ApiKeyInput

Inherits:
Object
  • Object
show all
Includes:
Formtastic::Inputs::Base
Defined in:
app/inputs/locomotive/api_key_input.rb

Instance Method Summary collapse

Instance Method Details

#api_key_htmlObject



20
21
22
23
# File 'app/inputs/locomotive/api_key_input.rb', line 20

def api_key_html
  api_key = self.object.api_key || I18n.t('locomotive.api_key.none')
  template. :code, api_key
end

#errors?Boolean

Returns:



35
36
37
# File 'app/inputs/locomotive/api_key_input.rb', line 35

def errors?
  false
end

#input_wrapping(&block) ⇒ Object



13
14
15
16
17
18
# File 'app/inputs/locomotive/api_key_input.rb', line 13

def input_wrapping(&block)
  template.(:li,
    [template.capture(&block), hint_html].join("\n").html_safe,
    wrapper_html_options
  )
end

#regenerate_buttonObject



25
26
27
28
29
30
31
32
33
# File 'app/inputs/locomotive/api_key_input.rb', line 25

def regenerate_button
  url = options[:url]
  template. :button, I18n.t('locomotive.api_key.button'),
    class:  'regenerate',
    data:   {
      url:      url,
      confirm:  I18n.t('locomotive.messages.confirm')
    }
end

#to_htmlObject



5
6
7
8
9
10
11
# File 'app/inputs/locomotive/api_key_input.rb', line 5

def to_html
  input_wrapping do
    label_html <<
    api_key_html <<
    regenerate_button
  end
end