Sha256: a785bb0ed6c6c6a3ddc600db59fd726e01d3c3c65b1b96097198e7cb57317765

Contents?: true

Size: 686 Bytes

Versions: 31

Compression:

Stored size: 686 Bytes

Contents

require 'active_admin/dynamic_setting'
require 'active_admin/settings_node'

module ActiveAdmin

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

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

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

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
activeadmin-rb-1.4.0 lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb
activeadmin-1.4.3 lib/active_admin/dynamic_settings_node.rb
activeadmin-1.4.2 lib/active_admin/dynamic_settings_node.rb
activeadmin-1.4.1 lib/active_admin/dynamic_settings_node.rb
activeadmin-1.4.0 lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/dynamic_settings_node.rb