Module: ActiveGeoDb
- Defined in:
- lib/active_geo_db.rb,
lib/active_geo_db/railtie.rb,
lib/active_geo_db/version.rb,
lib/active_geo_db/connection_provider.rb,
lib/active_geo_db/connection_configuration.rb
Defined Under Namespace
Classes: ConnectionConfiguration, ConnectionProvider, Railtie
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.coordinates(location) ⇒ Object
Find coordinates for a specific location.
-
.initialize(application) ⇒ Object
Initialize ActiveGeoDb: * Load configuration * Establish connection to OpenGeoDb database.
Class Method Details
.coordinates(location) ⇒ Object
Find coordinates for a specific location
17 18 19 20 21 22 23 24 |
# File 'lib/active_geo_db.rb', line 17 def self.coordinates(location) results = ConnectionProvider.connection.execute(%{ SELECT lat, lon FROM geodb_coordinates, geodb_textdata WHERE geodb_textdata.text_val = "#{location}" AND geodb_textdata.loc_id = geodb_coordinates.loc_id }).first end |
.initialize(application) ⇒ Object
Initialize ActiveGeoDb:
-
Load configuration
-
Establish connection to OpenGeoDb database
10 11 12 13 14 |
# File 'lib/active_geo_db.rb', line 10 def self.initialize(application) connection_configuration_path = application.paths["config/database"].first ConnectionConfiguration.instance.load_file(connection_configuration_path) ConnectionProvider.establish_connection(ConnectionConfiguration.instance.to_hash) end |