Module: F00px::Configuration::Options::ClassMethods

Defined in:
lib/f00px/configuration/options.rb

Instance Method Summary collapse

Instance Method Details

#defaultsObject



11
12
13
# File 'lib/f00px/configuration/options.rb', line 11

def defaults
  @defaults ||= {}
end

#option(name, options = {}) ⇒ Object



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

def option(name, options = {})
  self.defaults[name] = options[:default]

  class_eval <<-RUBY
    def #{name}
      settings['#{name}'.to_sym] || #{self}.defaults['#{name}'.to_sym]
    end

    def #{name}=(value)
      settings['#{name}'.to_sym] = value
    end

    def #{name}?
      !!#{name}
    end
  RUBY
end

#optionsObject



15
16
17
# File 'lib/f00px/configuration/options.rb', line 15

def options
  self.defaults.keys
end