Module: Golden::Setting::SettingsHelper

Defined in:
app/helpers/golden/setting/settings_helper.rb

Instance Method Summary collapse

Instance Method Details

#setting_field_typesObject



8
9
10
11
12
13
# File 'app/helpers/golden/setting/settings_helper.rb', line 8

def setting_field_types
  Golden::Setting.field_types.map do |key, value|
    next if key.nil? or value.nil?
    [I18n.t(key, scope: 'golden.setting.field_types'), value.to_sym]
  end
end

#setting_field_values(collection) ⇒ Object



15
16
17
18
19
# File 'app/helpers/golden/setting/settings_helper.rb', line 15

def setting_field_values collection
  return unless collection.present?
  return collection unless collection.respond_to? :id
  options_from_collection_for_select(collection, :id, :to_s, object.value)
end

#setting_groupsObject



21
22
23
24
25
26
# File 'app/helpers/golden/setting/settings_helper.rb', line 21

def setting_groups
  Golden::Setting.groups.map do |key, value|
    next if key.nil? or value.nil?
    [I18n.t(key, scope: 'golden.setting.groups'), value.to_s]
  end
end

#setting_name(name) ⇒ Object



28
29
30
# File 'app/helpers/golden/setting/settings_helper.rb', line 28

def setting_name name
  I18n.t(name, scope: 'golden.setting.names')
end

#setting_selectable?(field_type) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/helpers/golden/setting/settings_helper.rb', line 4

def setting_selectable? field_type
  !%w{string boolean}.include? field_type
end

#settings_nav_tab(name, default) ⇒ Object



32
33
34
35
# File 'app/helpers/golden/setting/settings_helper.rb', line 32

def settings_nav_tab name, default
  text = I18n.t(name, scope: 'golden.setting.groups')
  nav_tab text, "settings-#{name}", "settings-#{default}"
end

#settings_tab_pane(name, default, &block) ⇒ Object



37
38
39
# File 'app/helpers/golden/setting/settings_helper.rb', line 37

def settings_tab_pane name, default, &block
  tab_pane "settings-#{name}", "settings-#{default}", &block
end

#skip_setting?(setting) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/helpers/golden/setting/settings_helper.rb', line 47

def skip_setting? setting
  Golden::Setting.skip_settings.include? setting
end

#skip_setting_group?(group) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'app/helpers/golden/setting/settings_helper.rb', line 41

def skip_setting_group? group
  method = Golden::Setting.skip_groups_method
  skiped = (method and respond_to?(method) and send(method, group))
  group.blank? or skiped
end