Class: StoreSchema::Converter::Boolean
- Inherits:
-
Object
- Object
- StoreSchema::Converter::Boolean
- Includes:
- Base
- 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.
24 25 26 |
# File 'lib/store_schema/converter/boolean.rb', line 24 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
20 21 22 |
# File 'lib/store_schema/converter/boolean.rb', line 20 def value @value end |
Instance Method Details
#from_db ⇒ true, false
Converts the #value to a Ruby-type value.
46 47 48 |
# File 'lib/store_schema/converter/boolean.rb', line 46 def from_db value == DB_TRUE_VALUE end |