Class: StoreSchema::Converter::Boolean
- Defined in:
- lib/store_schema/converter/boolean.rb
Constant Summary collapse
- DB_TRUE_VALUE =
Returns the database representation of a true value.
"t"- TRUE_VALUES =
Returns all the values that are considered to be truthy.
[true, 1, "1", "t", "T", "true", "TRUE", "on", "ON"]
- FALSE_VALUES =
Returns all the values that are considered to be falsy.
[false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"]
Instance Attribute Summary collapse
- #value ⇒ Object readonly
Instance Method Summary collapse
-
#from_db ⇒ true, false
Converts the #value to a Ruby-type value.
-
#initialize(value) ⇒ Boolean
constructor
A new instance of Boolean.
-
#to_db ⇒ String, false
Converts the #value to a database-storable value.
Constructor Details
#initialize(value) ⇒ Boolean
Returns a new instance of Boolean.
23 24 25 |
# File 'lib/store_schema/converter/boolean.rb', line 23 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
19 20 21 |
# File 'lib/store_schema/converter/boolean.rb', line 19 def value @value end |
Instance Method Details
#from_db ⇒ true, false
Converts the #value to a Ruby-type value.
45 46 47 |
# File 'lib/store_schema/converter/boolean.rb', line 45 def from_db value == DB_TRUE_VALUE end |