12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rlyeh/settings.rb', line 12
def set(option, value = nil, &block)
if option.respond_to?(:each)
option.each { |k, v| set k, v }
return self
end
setter = proc { |v| set option, v }
getter = block ? block : proc { value }
Rlyeh::Utils.singleton_class(self).class_eval do
define_method "#{option}=", &setter if setter
define_method "#{option}", &getter if getter
class_eval "def #{option}?; !!#{option}; end" unless method_defined?("#{option}?")
end
end
|