Class: ActiveAdmin::DynamicSettingsNode

Inherits:
SettingsNode show all
Defined in:
lib/active_admin/dynamic_settings_node.rb

Direct Known Subclasses

NamespaceSettings

Class Method Summary collapse

Methods inherited from SettingsNode

build

Class Method Details

.add_reader(name) ⇒ Object


15
16
17
18
19
# File 'lib/active_admin/dynamic_settings_node.rb', line 15

def add_reader(name)
  define_singleton_method(name) do |*args|
    send("#{name}_setting").value(*args)
  end
end

.add_writer(name, type) ⇒ Object


21
22
23
24
25
# File 'lib/active_admin/dynamic_settings_node.rb', line 21

def add_writer(name, type)
  define_singleton_method("#{name}=") do |value|
    send("#{name}_setting=", DynamicSetting.build(value, type))
  end
end

.register(name, value, type = nil) ⇒ Object


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

def register(name, value, type = nil)
  class_attribute "#{name}_setting"
  add_reader(name)
  add_writer(name, type)
  send "#{name}=", value
end