Class: Settis::IntegerSerializer
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Serializer
for, inherited, #initialize
Class Method Details
.serializes?(type) ⇒ Boolean
19
20
21
22
23
24
|
# File 'lib/settis/serializers/integer.rb', line 19
def self.serializes?(type)
case type
when :integer then true
when Class then type == Integer or type.ancestors.include?(Integer)
end
end
|
Instance Method Details
#deserialize(value) ⇒ Object
30
31
32
|
# File 'lib/settis/serializers/integer.rb', line 30
def deserialize(value)
value.to_i unless value.nil?
end
|
#serialize(value) ⇒ Object
26
27
28
|
# File 'lib/settis/serializers/integer.rb', line 26
def serialize(value)
value.to_i.to_s unless value.nil? or !value.respond_to?(:to_i)
end
|