Class: ActiveRecordMysqlSpatial::ActiveRecord::MySQL::Point
- Inherits:
-
Base
- Object
- ActiveRecord::Type::Json
- Base
- ActiveRecordMysqlSpatial::ActiveRecord::MySQL::Point
show all
- Defined in:
- lib/active_record_mysql_spatial/active_record/mysql/point.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#error, #error_backtrace, #raw
Instance Method Summary
collapse
Methods inherited from Base
#deserialize
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
7
8
9
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 7
def x
@x
end
|
#y ⇒ Object
Returns the value of attribute y.
7
8
9
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 7
def y
@y
end
|
Instance Method Details
#==(other) ⇒ Object
38
39
40
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 38
def ==(other)
super && x == other.x && y == other.y
end
|
#serialize(value) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 14
def serialize(value)
if value.is_a?(Point)
value
else
return unless valid_hash?(value, type: :point)
cast_value(value)
end
end
|
#to_coordinate_sql ⇒ Object
Also known as:
to_coordinates_sql
30
31
32
33
34
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 30
def to_coordinate_sql
return nil if @x.nil? || @y.nil?
"#{@x} #{@y}"
end
|
#to_sql ⇒ Object
24
25
26
27
28
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 24
def to_sql
return nil if @x.nil? || @y.nil?
"Point(#{to_coordinate_sql})"
end
|
#type ⇒ Object
10
11
12
|
# File 'lib/active_record_mysql_spatial/active_record/mysql/point.rb', line 10
def type
:point
end
|