Module: ActiveAdmin::Settings::ClassMethods

Defined in:
lib/active_admin/helpers/settings.rb

Instance Method Summary collapse

Instance Method Details

#default_settingsObject



57
58
59
# File 'lib/active_admin/helpers/settings.rb', line 57

def default_settings
  @default_settings ||= {}
end

#deprecated_setting(name, default, message = nil) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/active_admin/helpers/settings.rb', line 49

def deprecated_setting(name, default, message = nil)
  message = message || "The #{name} setting is deprecated and will be removed."
  setting(name, default)

  ActiveAdmin::Deprecation.deprecate self, name, message
  ActiveAdmin::Deprecation.deprecate self, :"#{name}=", message
end

#setting(name, default) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/active_admin/helpers/settings.rb', line 32

def setting(name, default)
  default_settings[name] = default
  attr_accessor(name)

  # Create an accessor that grabs from the defaults
  # if @name has not been set yet
  class_eval <<-EOC, __FILE__, __LINE__ + 1
    def #{name}
      if instance_variable_defined? :@#{name}
        @#{name}
      else
        default_settings[:#{name}]
      end
    end
  EOC
end