Module: ActiveAdmin::Settings::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#default_settingsObject



64
65
66
# File 'lib/active_admin/helpers/settings.rb', line 64

def default_settings
  @default_settings ||= {}
end

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



56
57
58
59
60
61
62
# File 'lib/active_admin/helpers/settings.rb', line 56

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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/active_admin/helpers/settings.rb', line 39

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
        read_default_setting(:#{name})
      end
    end
  EOC
end