Class: Parelation::Criteria::Where::Caster
- Inherits:
-
Object
- Object
- Parelation::Criteria::Where::Caster
- Defined in:
- lib/parelation/criteria/where/caster.rb
Constant Summary collapse
- TRUTHY_VALUES =
Returns an array of values that are considered true.
["1", "t", "true"]
- FALSY_VALUES =
Returns an array of values that are considered false.
["0", "f", "false"]
Instance Attribute Summary collapse
- #field ⇒ String readonly
- #klass ⇒ Class readonly
- #value ⇒ String readonly
Instance Method Summary collapse
- #cast ⇒ String, ...
-
#initialize(field, value, klass) ⇒ Caster
constructor
A new instance of Caster.
Constructor Details
#initialize(field, value, klass) ⇒ Caster
Returns a new instance of Caster.
27 28 29 30 31 |
# File 'lib/parelation/criteria/where/caster.rb', line 27 def initialize(field, value, klass) @field = field.to_s @value = value @klass = klass end |
Instance Attribute Details
#field ⇒ String (readonly)
13 14 15 |
# File 'lib/parelation/criteria/where/caster.rb', line 13 def field @field end |
#klass ⇒ Class (readonly)
21 22 23 |
# File 'lib/parelation/criteria/where/caster.rb', line 21 def klass @klass end |
#value ⇒ String (readonly)
17 18 19 |
# File 'lib/parelation/criteria/where/caster.rb', line 17 def value @value end |
Instance Method Details
#cast ⇒ String, ...
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/parelation/criteria/where/caster.rb', line 35 def cast case type when :boolean to_boolean when :integer to_integer when :float to_float when :datetime to_time else value end end |