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
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/libclimate/climate.rb', line 77 def Flag(name, ={}, &blk) f = self.Flag_old(name, ) # anticipate this functionality being added to CLASP unless f.respond_to? :action class << f attr_accessor :action end 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:
73 |
# File 'lib/libclimate/climate.rb', line 73 alias_method :Flag_old, :Flag |
.Option(name, options = {}, &blk) ⇒ Object
Defines an option, attaching the given block
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/libclimate/climate.rb', line 106 def Option(name, ={}, &blk) o = self.Option_old(name, ) # anticipate this functionality being added to CLASP unless o.respond_to? :action class << o attr_accessor :action end 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:
74 |
# File 'lib/libclimate/climate.rb', line 74 alias_method :Option_old, :Option |