Class: Neo4j::Shared::TypeConverters::BooleanConverter
- Inherits:
-
BaseConverter
- Object
- BaseConverter
- Neo4j::Shared::TypeConverters::BooleanConverter
- Defined in:
- lib/neo4j/shared/type_converters.rb
Constant Summary collapse
- FALSE_VALUES =
%w(n N no No NO false False FALSE off Off OFF f F).to_set
Class Method Summary collapse
- .converted?(value) ⇒ Boolean
- .converted_values ⇒ Object
- .db_type ⇒ Object (also: convert_type)
- .to_db(value) ⇒ Object (also: to_ruby)
Methods inherited from BaseConverter
Class Method Details
.converted?(value) ⇒ Boolean
110 111 112 |
# File 'lib/neo4j/shared/type_converters.rb', line 110 def converted?(value) converted_values.include?(value) end |
.converted_values ⇒ Object
114 115 116 |
# File 'lib/neo4j/shared/type_converters.rb', line 114 def converted_values [true, false] end |
.db_type ⇒ Object Also known as: convert_type
118 119 120 |
# File 'lib/neo4j/shared/type_converters.rb', line 118 def db_type Neo4j::Shared::Boolean end |
.to_db(value) ⇒ Object Also known as: to_ruby
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/neo4j/shared/type_converters.rb', line 124 def to_db(value) return false if FALSE_VALUES.include?(value) case value when TrueClass, FalseClass value when Numeric, /^\-?[0-9]/ !value.to_f.zero? else value.present? end end |