Class: Settis::BooleanSerializer

Inherits:
Serializer show all
Defined in:
lib/settis/serializers/boolean.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Serializer

for, inherited, #initialize

Constructor Details

This class inherits a constructor from Settis::Serializer

Class Method Details

.serializes?(type) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/settis/serializers/boolean.rb', line 19

def self.serializes?(type)
  type == :boolean
end

Instance Method Details

#deserialize(value) ⇒ Object



27
28
29
# File 'lib/settis/serializers/boolean.rb', line 27

def deserialize(value)
  value != 'false' unless value.nil?
end

#serialize(value) ⇒ Object



23
24
25
# File 'lib/settis/serializers/boolean.rb', line 23

def serialize(value)
  (value != false).to_s unless value.nil?
end