Class: RGeo::ActiveRecord::SpatialNamedFunction

Inherits:
Arel::Nodes::NamedFunction
  • Object
show all
Includes:
SpatialExpressions
Defined in:
lib/rgeo/active_record/arel_spatial_queries.rb

Overview

A NamedFunction subclass that keeps track of the spatial-ness of the arguments and return values, so that it can provide context to visitors that want to interpret syntax differently when dealing with spatial elements.

Instance Method Summary collapse

Methods included from SpatialExpressions

#st_area, #st_asbinary, #st_astext, #st_boundary, #st_buffer, #st_centroid, #st_contains, #st_convexhull, #st_crosses, #st_difference, #st_dimension, #st_disjoint, #st_distance, #st_endpoint, #st_envelope, #st_equals, #st_exteriorring, #st_function, #st_geometryn, #st_geometrytype, #st_interiorringn, #st_intersection, #st_intersects, #st_isclosed, #st_isempty, #st_isring, #st_issimple, #st_length, #st_m, #st_numgeometries, #st_numinteriorrings, #st_numpoints, #st_overlaps, #st_pointn, #st_pointonsurface, #st_relate, #st_srid, #st_startpoint, #st_symdifference, #st_touches, #st_union, #st_within, #st_x, #st_y, #st_z

Constructor Details

#initialize(name, expr, spatial_flags = [], aliaz = nil) ⇒ SpatialNamedFunction

Returns a new instance of SpatialNamedFunction.



100
101
102
103
104
105
106
107
108
# File 'lib/rgeo/active_record/arel_spatial_queries.rb', line 100

def initialize(name, expr, spatial_flags = [], aliaz = nil)
  if Arel::Nodes::NamedFunction.instance_method(:initialize).parameters.size == 2 # ActiveRecord 8.1+
    super(name, expr)
    @aliaz = aliaz
  else # ActiveRecord 8.0 and earlier
    super(name, expr, aliaz)
  end
  @spatial_flags = spatial_flags
end

Instance Method Details

#aliasObject



118
119
120
# File 'lib/rgeo/active_record/arel_spatial_queries.rb', line 118

def alias
  @aliaz || (instance_variable_defined?(:@alias) ? @alias : nil)
end

#spatial_argument?(index) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/rgeo/active_record/arel_spatial_queries.rb', line 114

def spatial_argument?(index)
  @spatial_flags[index + 1]
end

#spatial_result?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/rgeo/active_record/arel_spatial_queries.rb', line 110

def spatial_result?
  @spatial_flags.first
end