Class: CLASP
- Inherits:
-
Object
- Object
- CLASP
- Defined in:
- lib/libclimate/climate.rb
Overview
We monkey-patch CLASP module’s Flag and Option generator methods by added in an action attribute (but only if it does not exist) and attaching the given block
Class Method Summary collapse
-
.Flag(name, options = {}, &blk) ⇒ Object
Defines a flag, attaching the given block.
-
.Flag_old ⇒ Object
:nodoc:.
-
.Option(name, options = {}, &blk) ⇒ Object
Defines an option, attaching the given block.
-
.Option_old ⇒ Object
:nodoc:.
Class Method Details
.Flag(name, options = {}, &blk) ⇒ Object
Defines a flag, attaching the given block
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/libclimate/climate.rb', line 73 def Flag(name, ={}, &blk) f = self.Flag_old(name, ) # anticipate this functionality being added to CLASP return f if f.respond_to? :action class << f attr_accessor :action end if blk case blk.arity when 0, 1, 2 else warn "wrong arity for flag" end f.action = blk end f end |
.Flag_old ⇒ Object
:nodoc:
69 |
# File 'lib/libclimate/climate.rb', line 69 alias_method :Flag_old, :Flag |
.Option(name, options = {}, &blk) ⇒ Object
Defines an option, attaching the given block
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/libclimate/climate.rb', line 101 def Option(name, ={}, &blk) o = self.Option_old(name, ) # anticipate this functionality being added to CLASP return o if o.respond_to? :action class << o attr_accessor :action end if blk case blk.arity when 0, 1, 2 else warn "wrong arity for option" end o.action = blk end o end |
.Option_old ⇒ Object
:nodoc:
70 |
# File 'lib/libclimate/climate.rb', line 70 alias_method :Option_old, :Option |