Class: Baboon::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/baboon/configuration.rb

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/baboon/configuration.rb', line 17

def initialize
  # Cannot call attr inside of class, need to class_eval it
  class << self
    self
  end.class_eval do
    # Define all of the attributes
    BABOON_CONFIGURATION_OPTIONS.each do |name|
      attr_accessor name

      # For each given symbol we generate accessor method that sets option's
      # value being called with an argument, or returns option's current value
      # when called without arguments
      define_method name do |*values|
        value = values.first
        value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
      end
    end
  end
  # Initialize defaults
end