Module: Arturo::FeaturesHelper

Includes:
ActionView::Helpers::TagHelper
Defined in:
app/helpers/arturo/features_helper.rb

Instance Method Summary collapse

Instance Method Details

#arturo_flash_message(status, message) ⇒ Object



14
15
16
17
18
19
# File 'app/helpers/arturo/features_helper.rb', line 14

def arturo_flash_message(status, message)
  (:div, :class => "alert alert-#{status} alert-arturo") do
    close = (:a, '×'.html_safe, :href => '#', :class => 'close', 'data-dismiss' => 'alert')
    (:span, message) + close
  end
end

#arturo_flash_messages(flash = self.flash) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/helpers/arturo/features_helper.rb', line 5

def arturo_flash_messages(flash = self.flash)
  [ :success, :notice, :error ].inject(''.html_safe) do |output, status|
    [* flash[status] ].each do |messages|
      output += arturo_flash_message(status, messages)
    end
    output
  end
end

#deployment_percentage_output_tag(id, value) ⇒ Object



36
37
38
# File 'app/helpers/arturo/features_helper.rb', line 36

def deployment_percentage_output_tag(id, value)
  (:output, value, { 'for' => id, 'class' => 'deployment_percentage no_js' })
end

#deployment_percentage_range_and_output_tags(name, value, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/arturo/features_helper.rb', line 21

def deployment_percentage_range_and_output_tags(name, value, options = {})
  id = sanitize_to_id(name)
  options = {
    'type' => 'range',
    'name' => name,
    'id' => id,
    'value' => value,
    'min' => '0',
    'max' => '100',
    'step' => '1',
    'class' => 'deployment_percentage'
  }.update(options.stringify_keys)
  tag(:input, options) + deployment_percentage_output_tag(id, value)
end

#error_messages_for_feature(feature, attribute) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'app/helpers/arturo/features_helper.rb', line 40

def error_messages_for_feature(feature, attribute)
  if feature.errors[attribute].any?
    (:ul, :class => 'errors') do
      feature.errors[attribute].map { |msg| (:li, msg, :class => 'error') }.join('').html_safe
    end
  else
    ''
  end
end