Class: Armg::MysqlGeometry

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/armg/mysql_geometry.rb

Instance Method Summary collapse

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/armg/mysql_geometry.rb', line 9

def binary?
  true
end

#deserialize(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/armg/mysql_geometry.rb', line 13

def deserialize(value)
  case value
  when ::String
    Armg.deserializer.deserialize(value)
  when ActiveModel::Type::Binary::Data
    Armg.deserializer.deserialize(value.to_s)
  else
    value
  end
end

#serialize(value) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/armg/mysql_geometry.rb', line 24

def serialize(value)
  if value.nil?
    nil
  else
    value = Armg.serializer.serialize(value)
    ActiveModel::Type::Binary::Data.new(value)
  end
end

#typeObject



5
6
7
# File 'lib/armg/mysql_geometry.rb', line 5

def type
  :geometry
end