Class: Transcriber::Resource::Serialization::Boolean
- Inherits:
-
Object
- Object
- Transcriber::Resource::Serialization::Boolean
- Defined in:
- lib/transcriber/resource/serialization/boolean.rb
Constant Summary collapse
- MAPPINGS =
{ true => true, "true" => true, "TRUE" => true, "1" => true, 1 => true, 1.0 => true, "x" => true, "X" => true, "t" => true, "T" => true, false => false, "false" => false, "FALSE" => false, "0" => false, 0 => false, 0.0 => false, "" => false, " " => false, "f" => false, "F" => false, nil => false }.freeze
Class Method Summary collapse
Class Method Details
.desserialize(value) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/transcriber/resource/serialization/boolean.rb', line 35 def self.desserialize(value) fail unless boolean?(value) value ? Transcriber.configuration.true_value : Transcriber.configuration.false_value end |
.serialize(value) ⇒ Object
29 30 31 32 33 |
# File 'lib/transcriber/resource/serialization/boolean.rb', line 29 def self.serialize(value) MAPPINGS[value].tap do |bool| fail "value not serializable: #{value}" if bool.nil? end end |