Module: CastingInterfaceMethods

Defined in:
lib/Switches.rb

Instance Method Summary collapse

Instance Method Details

#array(*attrs, &block) ⇒ Object



122
123
124
125
# File 'lib/Switches.rb', line 122

def array(*attrs, &block)
  attrs.poke_options!({:cast => Array})
  set(*attrs, &block)
end

#array!(*attrs, &block) ⇒ Object



127
128
129
130
# File 'lib/Switches.rb', line 127

def array!(*attrs, &block)
  attrs.poke_options!({:cast => Array})
  set!(*attrs, &block)
end

#boolean(*attrs, &block) ⇒ Object Also known as: flag



144
145
146
147
# File 'lib/Switches.rb', line 144

def boolean(*attrs, &block)
  attrs.collect!{|a| a.to_s =~ /\?$/ ? a : (a.to_s + '?').to_sym}
  set(*attrs, &block)
end

#float(*attrs, &block) ⇒ Object



112
113
114
115
# File 'lib/Switches.rb', line 112

def float(*attrs, &block)
  attrs.poke_options!({:cast => Float})
  set(*attrs, &block)
end

#float!(*attrs, &block) ⇒ Object



117
118
119
120
# File 'lib/Switches.rb', line 117

def float!(*attrs, &block)
  attrs.poke_options!({:cast => Float})
  set!(*attrs, &block)
end

#integer(*attrs, &block) ⇒ Object



102
103
104
105
# File 'lib/Switches.rb', line 102

def integer(*attrs, &block)
  attrs.poke_options!({:cast => Integer})
  set(*attrs, &block)
end

#integer!(*attrs, &block) ⇒ Object



107
108
109
110
# File 'lib/Switches.rb', line 107

def integer!(*attrs, &block)
  attrs.poke_options!({:cast => Integer})
  set!(*attrs, &block)
end

#regexp(*attrs, &block) ⇒ Object Also known as: regex



132
133
134
135
# File 'lib/Switches.rb', line 132

def regexp(*attrs, &block)
  attrs.poke_options!({:cast => Regexp})
  set(*attrs, &block)
end

#regexp!(*attrs, &block) ⇒ Object Also known as: regex!



138
139
140
141
# File 'lib/Switches.rb', line 138

def regexp!(*attrs, &block)
  attrs.poke_options!({:cast => Regexp})
  set!(*attrs, &block)
end