module BookingLocations
Constants
- DEFAULT_PREFIX
- DEFAULT_TTL
- KNOWN_LOCATION_IDS
- VERSION
Public Class Methods
all()
click to toggle source
# File lib/booking_locations.rb, line 31 def self.all api.all.map do |location| Location.new(location) end end
api()
click to toggle source
# File lib/booking_locations.rb, line 15 def self.api @@api ||= BookingLocations::Api.new end
cache()
click to toggle source
# File lib/booking_locations.rb, line 19 def self.cache @@cache ||= ActiveSupport::Cache::NullStore.new end
cache_prefix(key)
click to toggle source
# File lib/booking_locations.rb, line 41 def self.cache_prefix(key) DEFAULT_PREFIX.dup.concat(key) end
clear_cache()
click to toggle source
# File lib/booking_locations.rb, line 37 def self.clear_cache cache.delete_matched(cache_prefix('*')) end
find(id, expires = DEFAULT_TTL)
click to toggle source
# File lib/booking_locations.rb, line 23 def self.find(id, expires = DEFAULT_TTL) cache.fetch(cache_prefix(id), expires_in: expires) do api.get(id) do |response_hash| Location.new(response_hash) end end end