Module: CastingInterfaceMethods
- Defined in:
- lib/Switches.rb
Instance Method Summary collapse
- #array(*attrs, &block) ⇒ Object
- #array!(*attrs, &block) ⇒ Object
- #boolean(*attrs, &block) ⇒ Object (also: #flag)
- #float(*attrs, &block) ⇒ Object
- #float!(*attrs, &block) ⇒ Object
- #integer(*attrs, &block) ⇒ Object
- #integer!(*attrs, &block) ⇒ Object
- #regexp(*attrs, &block) ⇒ Object (also: #regex)
- #regexp!(*attrs, &block) ⇒ Object (also: #regex!)
Instance Method Details
#array(*attrs, &block) ⇒ Object
123 124 125 126 |
# File 'lib/Switches.rb', line 123 def array(*attrs, &block) attrs.({:cast => Array}) set(*attrs, &block) end |
#array!(*attrs, &block) ⇒ Object
128 129 130 131 |
# File 'lib/Switches.rb', line 128 def array!(*attrs, &block) attrs.({:cast => Array}) set!(*attrs, &block) end |
#boolean(*attrs, &block) ⇒ Object Also known as: flag
145 146 147 148 |
# File 'lib/Switches.rb', line 145 def boolean(*attrs, &block) attrs.collect!{|a| a.to_s =~ /\?$/ ? a : (a.to_s + '?').to_sym} set(*attrs, &block) end |
#float(*attrs, &block) ⇒ Object
113 114 115 116 |
# File 'lib/Switches.rb', line 113 def float(*attrs, &block) attrs.({:cast => Float}) set(*attrs, &block) end |
#float!(*attrs, &block) ⇒ Object
118 119 120 121 |
# File 'lib/Switches.rb', line 118 def float!(*attrs, &block) attrs.({:cast => Float}) set!(*attrs, &block) end |
#integer(*attrs, &block) ⇒ Object
103 104 105 106 |
# File 'lib/Switches.rb', line 103 def integer(*attrs, &block) attrs.({:cast => Integer}) set(*attrs, &block) end |
#integer!(*attrs, &block) ⇒ Object
108 109 110 111 |
# File 'lib/Switches.rb', line 108 def integer!(*attrs, &block) attrs.({:cast => Integer}) set!(*attrs, &block) end |
#regexp(*attrs, &block) ⇒ Object Also known as: regex
133 134 135 136 |
# File 'lib/Switches.rb', line 133 def regexp(*attrs, &block) attrs.({:cast => Regexp}) set(*attrs, &block) end |
#regexp!(*attrs, &block) ⇒ Object Also known as: regex!
139 140 141 142 |
# File 'lib/Switches.rb', line 139 def regexp!(*attrs, &block) attrs.({:cast => Regexp}) set!(*attrs, &block) end |