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.
6 7 8 9 10 11 12 13 14 |
# File 'lib/halo-api/client.rb', line 6 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
25 26 27 28 29 30 31 |
# File 'lib/halo-api/client.rb', line 25 def cache_store { redis: @redis, ttl: @ttl, cached: @cached } end |
#cached? ⇒ Boolean
Returns true if the request should be cached.
34 35 36 |
# File 'lib/halo-api/client.rb', line 34 def cached? cache_store[:cached] end |
#set_up_cache(redis_url, ttl) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/halo-api/client.rb', line 16 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 |