Class: Halo::Client
Direct Known Subclasses
Instance Method Summary collapse
-
#cache_store ⇒ Hash
Returns an options hash with cache keys.
-
#cached? ⇒ Boolean
True if the request should be cached.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #set_up_cache(redis_url, ttl) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 |
# File 'lib/halo-api/client.rb', line 14 def initialize( = {}) = Halo..merge() Halo::Configuration::OPTIONS.each do |key| send("#{key}=", [key]) end set_up_cache(.delete(:redis), .delete(:ttl)) end |
Instance Method Details
#cache_store ⇒ Hash
Returns an options hash with cache keys
33 34 35 36 37 38 39 |
# File 'lib/halo-api/client.rb', line 33 def cache_store { redis: @redis, ttl: @ttl, cached: @cached } end |
#cached? ⇒ Boolean
Returns true if the request should be cached.
42 43 44 |
# File 'lib/halo-api/client.rb', line 42 def cached? cache_store[:cached] end |
#set_up_cache(redis_url, ttl) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/halo-api/client.rb', line 24 def set_up_cache(redis_url, ttl) return @cached = false unless redis_url @ttl = ttl || Halo::Configuration::DEFAULT_TTL @cached = true @redis = Redis.new url: redis_url end |