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
113 114 115 116 |
# File 'lib/Switches.rb', line 113 def array(*attrs, &block) attrs.({:cast => Array}) set(*attrs, &block) end |
#array!(*attrs, &block) ⇒ Object
118 119 120 121 |
# File 'lib/Switches.rb', line 118 def array!(*attrs, &block) attrs.({:cast => Array}) set!(*attrs, &block) end |
#boolean(*attrs, &block) ⇒ Object Also known as: flag
135 136 137 138 |
# File 'lib/Switches.rb', line 135 def boolean(*attrs, &block) attrs.collect!{|a| a.to_s =~ /\?$/ ? a : (a.to_s + '?').to_sym} set(*attrs, &block) end |
#float(*attrs, &block) ⇒ Object
103 104 105 106 |
# File 'lib/Switches.rb', line 103 def float(*attrs, &block) attrs.({:cast => Float}) set(*attrs, &block) end |
#float!(*attrs, &block) ⇒ Object
108 109 110 111 |
# File 'lib/Switches.rb', line 108 def float!(*attrs, &block) attrs.({:cast => Float}) set!(*attrs, &block) end |
#integer(*attrs, &block) ⇒ Object
93 94 95 96 |
# File 'lib/Switches.rb', line 93 def integer(*attrs, &block) attrs.({:cast => Integer}) set(*attrs, &block) end |
#integer!(*attrs, &block) ⇒ Object
98 99 100 101 |
# File 'lib/Switches.rb', line 98 def integer!(*attrs, &block) attrs.({:cast => Integer}) set!(*attrs, &block) end |
#regexp(*attrs, &block) ⇒ Object Also known as: regex
123 124 125 126 |
# File 'lib/Switches.rb', line 123 def regexp(*attrs, &block) attrs.({:cast => Regexp}) set(*attrs, &block) end |
#regexp!(*attrs, &block) ⇒ Object Also known as: regex!
129 130 131 132 |
# File 'lib/Switches.rb', line 129 def regexp!(*attrs, &block) attrs.({:cast => Regexp}) set!(*attrs, &block) end |