Module: Configurable
- Included in:
- Midori::Configure
- Defined in:
- lib/midori/core_ext/configurable.rb
Overview
Modified from Sinatra Provide flexible configuration for Midori Server
Instance Method Summary collapse
-
#set(option, value = (not_set = true), read_only = false) ⇒ nil
Sets an option to the given value.
Instance Method Details
#set(option, value = (not_set = true), read_only = false) ⇒ nil
Sets an option to the given value.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/midori/core_ext/configurable.rb', line 10 def set(option, value = (not_set = true), read_only = false) raise ArgumentError if not_set setter = proc { |val| set option, val } getter = proc { value } define_singleton("#{option}=", setter) unless read_only define_singleton(option, getter) define_singleton("#{option}?", "!!#{option}") unless method_defined? "#{option}?" self end |