class StoreSchema::Converter::Boolean
Constants
- DB_FALSE_VALUE
@return [String] the database representation of a false value.
- DB_TRUE_VALUE
@return [String] the database representation of a true value.
- FALSE_VALUES
@return [Array] all the values that are considered to be falsy.
- TRUE_VALUES
@return [Array] all the values that are considered to be truthy.
Attributes
value[R]
@return [Object]
Public Class Methods
new(value)
click to toggle source
@param [Object] value
# File lib/store_schema/converter/boolean.rb, line 29 def initialize(value) @value = value end
Public Instance Methods
from_db()
click to toggle source
Converts the {#value} to a Ruby-type value.
@return [true, false]
# File lib/store_schema/converter/boolean.rb, line 51 def from_db value == DB_TRUE_VALUE end
to_db()
click to toggle source
Converts the {#value} to a database-storable value.
@return [String, false] false if {#value} is an invalid date-type.
# File lib/store_schema/converter/boolean.rb, line 37 def to_db if TRUE_VALUES.include?(value) DB_TRUE_VALUE elsif FALSE_VALUES.include?(value) DB_FALSE_VALUE else false end end