Skip to content
Snippets Groups Projects
Commit 337430ae authored by Alex Reisner's avatar Alex Reisner
Browse files

Move Geocoder.cache method to lib/geocoder.rb.

parent 2da7dfe8
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,16 @@ module Geocoder ...@@ -34,6 +34,16 @@ module Geocoder
end end
end end
##
# The working Cache object, or +nil+ if none configured.
#
def cache
if @cache.nil? and store = Configuration.cache
@cache = Cache.new(store, Configuration.cache_prefix)
end
@cache
end
# exception classes # exception classes
class Error < StandardError; end class Error < StandardError; end
...@@ -50,7 +60,7 @@ module Geocoder ...@@ -50,7 +60,7 @@ module Geocoder
if ip if ip
get_lookup :freegeoip get_lookup :freegeoip
else else
get_lookup Geocoder::Configuration.lookup || :google get_lookup Configuration.lookup || :google
end end
end end
......
module Geocoder module Geocoder
##
# The working Cache object, or +nil+ if none configured.
#
def self.cache
if @cache.nil? and store = Geocoder::Configuration.cache
@cache = Cache.new(store, Geocoder::Configuration.cache_prefix)
end
@cache
end
class Cache class Cache
def initialize(store, prefix) def initialize(store, prefix)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment