Module: ActiveRecordPostgresEarthdistance::ActsAsGeolocated::Utils
- Defined in:
- lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb
Class Method Summary collapse
- .ll_to_earth_columns(klass) ⇒ Object
- .ll_to_earth_coords(lat, lng) ⇒ Object
- .quote_value(value) ⇒ Object
Class Method Details
.ll_to_earth_columns(klass) ⇒ Object
31 32 33 |
# File 'lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb', line 31 def self.ll_to_earth_columns(klass) Arel::Nodes::NamedFunction.new('ll_to_earth', [klass.arel_table[klass.latitude_column], klass.arel_table[klass.longitude_column]]) end |
.ll_to_earth_coords(lat, lng) ⇒ Object
35 36 37 |
# File 'lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb', line 35 def self.ll_to_earth_coords lat, lng Arel::Nodes::NamedFunction.new('ll_to_earth', [quote_value(lat), quote_value(lng)]) end |
.quote_value(value) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb', line 39 def self.quote_value value if Arel::Nodes.respond_to?(:build_quoted) # for arel >= 6.0.0 Arel::Nodes.build_quoted(value) else value end end |