Method: ActiveConfiguration::Base#option
- Defined in:
- lib/active_configuration/base.rb
#option(key, &block) ⇒ Object
Creates and accepts the configuration details for an Option.
An example of setting an option with a block:
option :sort do
default 'alphabetical'
restrict 'alphabetical', 'manual'
end
Here, the #option method is called and passed the key of :sort and then the the block that follows. The block given to #option is then evaluated against a new instance of ActiveConfiguration::Option.
32 33 34 35 36 |
# File 'lib/active_configuration/base.rb', line 32 def option(key, &block) opt = Option.new(key) opt.instance_eval(&block) [key.to_sym] = opt end |