Module: Rea::Settings::ClassMethods

Defined in:
lib/rea/settings.rb

Instance Method Summary collapse

Instance Method Details

#default_settingsObject



52
53
54
# File 'lib/rea/settings.rb', line 52

def default_settings
  @default_settings ||= {}
end

#setting(name, default) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rea/settings.rb', line 35

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