Module: Configuration

Included in:
UseTheForce
Defined in:
lib/use_the_force/configuration.rb

Instance Method Summary collapse

Instance Method Details

#configuration {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Configuration)

    the object that the method was called on



2
3
4
# File 'lib/use_the_force/configuration.rb', line 2

def configuration
  yield self
end

#define_configurables(*names, default: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/use_the_force/configuration.rb', line 6

def define_configurables(*names, default: nil)
  names.each do |name|
    class_variable_set(:"@@#{name}", default)

    define_class_method "#{name}=" do |value|
      class_variable_set(:"@@#{name}", value)
    end

    define_class_method name do
      class_variable_get(:"@@#{name}")
    end
  end
end