def verbose(value) @options[:verbose] = value end def format(value) @options[:format] = value end end def verbose=(value) @options[:verbose] = value end def format=(value) @options[:format] = value end
@options[:format] = value end def enabled=(value) @options[:enabled] = value end def fail_fast=(value) @options[:fail_fast] = value end def verbose=(value) @options[:verbose] = value end def format=(value) @options[:format] = value end def enabled=(value) @options[:enabled] = value end def fail_fast=(value) @options[:fail_fast] = value end def verbose=(value) @options[:enabled] = value end def fail_fast=(value) @options[:fail_fast] = value end def verbose=(value) @options[:verbose] = value end def format=(value) @options[:format] = value end def enabled=(value) @options[:enabled] = value end def fail_fast=(value) @options[:fail_fast] = value end def verbose=(value) @options[:verbose] = value end def format=(value) @options[:format] = value end def format=(value) @options[:format] = end def enabled=(value) @options[:enabled] end def fail_fast=(value) @options[:fail_fast end def verbose=(value) @options[:verbose] end def format=(value) @options[:format] = end def enabled=(value) @options[:enabled] end def fail_fast=(value) @options[:fail_fast end def verbose=(value) @options[:verbose]
@options[method_name[0..-1]] = value else super # Fall back behavior end end end config = Config.new config.verbose = true config.format = :documentation
|value| options[option_name] = value end end end def_options :verbose, :format # ... end config = Config.new config.verbose = true config.format = :documentation
|value| options[option_name] = value end end end def_options :verbose, :format # ... end config = Config.new config.verbose = true config.format = :documentation def_options :verbose, :format
|value| options[option_name] = value end end end def_options :verbose, :format # ... end config = Config.new config.verbose = true config.format = :documentation def self.def_options(*option_names) option_names.each do |option_name|
|value| options[option_name] = value end end end def_options :verbose, :format # ... end config = Config.new config.verbose = true config.format = :documentation define_method "#{option_name}=" do |value| options[option_name] = value end
def_options :verbose, :format end def output(&block) @output ||= Output.new @output.instance_eval(&block) if block_given? @output end end def output(&block) @output ||= Output.new @output.instance_eval(&block) if block_given? @output end
{} end option_names.each do |option_name| define_method option_name do |value| options[option_name] = value end end end define_method option_name do |value| options[option_name] = value end
||= {} end option_names.each do |option_name| define_method option_name do |value| options[option_name] = value end end define_method :options do @options ||= {} end define_method option_name do |value| options[option_name] = value end
... end Config.configure do verbose true format :documentation end class ConfigDSL include ConfigOption.new( :verbose, :format) def self.dsl(&block) instance = new instance .instance_eval(&block) instance end end
... end Config.configure do verbose true format :documentation end class ConfigDSL include ConfigOption.new( :verbose, :format) def self.dsl(&block) instance = new instance .instance_eval(&block) instance end end dsl = ConfigDSL.dsl(&block) new(dsl.options) class ConfigDSL def self.dsl(&block)