Module: Rack::Zippy::Configuration

Included in:
Rack::Zippy
Defined in:
lib/rack-zippy/configuration.rb

Instance Method Summary collapse

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



4
5
6
# File 'lib/rack-zippy/configuration.rb', line 4

def configure
  yield self
end

#define_setting(name, default = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rack-zippy/configuration.rb', line 8

def define_setting(name, default = nil)
  default_copy = begin
                   default.dup
  rescue TypeError
                   default
  end
  class_variable_set("@@#{name}", default_copy)

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