Module: EacRubyUtils::SettingsProvider

Defined in:
lib/eac_ruby_utils/settings_provider.rb,
lib/eac_ruby_utils/settings_provider/setting_value.rb

Overview

Provide a option by constant, method or options object.

Defined Under Namespace

Classes: SettingValue

Instance Method Summary collapse

Instance Method Details

#setting_constant_name(key, fullname = false) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



11
12
13
# File 'lib/eac_ruby_utils/settings_provider.rb', line 11

def setting_constant_name(key, fullname = false) # rubocop:disable Style/OptionalBooleanParameter
  setting_value_instance(key).constant_name(fullname)
end

#setting_search_orderObject



15
16
17
# File 'lib/eac_ruby_utils/settings_provider.rb', line 15

def setting_search_order
  %w[settings_object method constant]
end

#setting_value(key, options = {}) ⇒ Object



30
31
32
# File 'lib/eac_ruby_utils/settings_provider.rb', line 30

def setting_value(key, options = {})
  setting_value_instance(key, options).value
end

#setting_value_by_constant(key) ⇒ Object



34
35
36
# File 'lib/eac_ruby_utils/settings_provider.rb', line 34

def setting_value_by_constant(key)
  setting_value_instance(key).value_by_constant
end

#setting_value_by_method(key) ⇒ Object



38
39
40
# File 'lib/eac_ruby_utils/settings_provider.rb', line 38

def setting_value_by_method(key)
  setting_value_instance(key).value_by_method
end

#setting_value_by_settings_object(key) ⇒ Object



42
43
44
# File 'lib/eac_ruby_utils/settings_provider.rb', line 42

def setting_value_by_settings_object(key)
  setting_value_instance(key).value_by_settings_object
end

#setting_value_instance(key, options = {}) ⇒ Object



46
47
48
# File 'lib/eac_ruby_utils/settings_provider.rb', line 46

def setting_value_instance(key, options = {})
  ::EacRubyUtils::SettingsProvider::SettingValue.new(self, key, options)
end

#settings_objectObject

return [ActiveSupport::HashWithIndifferentAccess]



20
21
22
23
24
# File 'lib/eac_ruby_utils/settings_provider.rb', line 20

def settings_object
  ActiveSupport::HashWithIndifferentAccess.new(
    respond_to?(settings_object_name) ? send(settings_object_name) : {}
  )
end

#settings_object_nameObject



26
27
28
# File 'lib/eac_ruby_utils/settings_provider.rb', line 26

def settings_object_name
  'settings'
end