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.


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

def initialize(setting)
  @setting = setting
end

Class Method Details

.build(setting, type) ⇒ Object


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

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

.klass(type) ⇒ Object

Raises:

  • (ArgumentError)

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

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


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

def value(*_args)
  @setting
end