Class: Halo::Client
- Inherits:
-
Object
- Object
- Halo::Client
- Defined in:
- lib/halo-api/client.rb
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.
7 8 9 10 11 12 13 14 15 |
# File 'lib/halo-api/client.rb', line 7 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
27 28 29 30 31 32 33 |
# File 'lib/halo-api/client.rb', line 27 def cache_store { redis: @redis, ttl: @ttl, cached: @cached } end |
#cached? ⇒ Boolean
Returns true if the request should be cached.
36 37 38 |
# File 'lib/halo-api/client.rb', line 36 def cached? cache_store[:cached] end |
#set_up_cache(redis_url, ttl) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/halo-api/client.rb', line 17 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 |