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


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

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


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

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


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

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


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

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


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

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