Class: Warped::Filter::Boolean
- Defined in:
- lib/warped/api/filter/boolean.rb
Defined Under Namespace
Classes: Value
Constant Summary collapse
- RELATIONS =
%w[eq neq is_null is_not_null].freeze
Instance Attribute Summary
Attributes inherited from Base
#alias_name, #name, #options, #strict
Instance Method Summary collapse
Methods inherited from Base
#initialize, kind, #kind, #parameter_name, #relation, #relations
Constructor Details
This class inherits a constructor from Warped::Filter::Base
Instance Method Details
#cast(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/warped/api/filter/boolean.rb', line 8 def cast(value) return if value.nil? casted_value = case value when true, false value when "true", "1", "t", 1 true when "false", "0", "f", 0 false end casted_value.tap do |casted| raise ValueError, "#{value} cannot be casted to #{kind}" if casted.nil? && strict end end |
#html_type ⇒ Object
25 26 27 |
# File 'lib/warped/api/filter/boolean.rb', line 25 def html_type "text" end |