Module: CP::Has::Options
Instance Method Summary collapse
Instance Method Details
#option(*args) {|opt| ... } ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cp/has/options.rb', line 9 def option( *args ) opt = CP::Option.new( *args ) yield opt if block_given? if( respond_to?( :ancestors, true ) ) parent_opt = ancestors[1..-1].reverse.inject( {} ) { |opts, c| opts.merge( c. ) }[opt.name] opt = parent_opt.merge( opt ) if parent_opt end [opt.name] = opt opt end |
#options ⇒ Object
4 5 6 7 |
# File 'lib/cp/has/options.rb', line 4 def @options ||= {} @options end |