Class: ActiveAdmin::DynamicSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/dynamic_setting.rb

Direct Known Subclasses

StringSymbolOrProcSetting

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setting) ⇒ DynamicSetting

Returns a new instance of DynamicSetting.



15
16
17
# File 'lib/active_admin/dynamic_setting.rb', line 15

def initialize(setting)
  @setting = setting
end

Class Method Details

.build(setting, type) ⇒ Object



5
6
7
# File 'lib/active_admin/dynamic_setting.rb', line 5

def self.build(setting, type)
  (type ? klass(type) : self).new(setting)
end

.klass(type) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/active_admin/dynamic_setting.rb', line 9

def self.klass(type)
  klass = "#{type.to_s.camelcase}Setting"
  raise ArgumentError, "Unknown type: #{type}" unless ActiveAdmin.const_defined?(klass)
  ActiveAdmin.const_get(klass)
end

Instance Method Details

#value(*_args) ⇒ Object



19
20
21
# File 'lib/active_admin/dynamic_setting.rb', line 19

def value(*_args)
  @setting
end