Class: GIDSRedis
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- GIDSRedis
- Includes:
- Common::CacheAside
- Defined in:
- app/models/gids_redis.rb
Overview
Facade for GIDS.
Constant Summary
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Instance Attribute Summary collapse
-
#rest_call ⇒ Symbol
The GI::Client method to call.
-
#scrubbed_params ⇒ Hash
The params to be used with the rest_call.
Instance Method Summary collapse
- #gi_lce_service ⇒ Object private
- #gi_search_service ⇒ Object private
- #gi_service ⇒ Object private
- #lce_respond_to?(name) ⇒ Boolean
- #method_missing(name, *args) ⇒ Object
- #respond_to_missing?(name, _include_private) ⇒ Boolean
- #response_from_redis_or_service(service) ⇒ Object private
- #search_respond_to?(name) ⇒ Boolean
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with, #set_attributes
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/gids_redis.rb', line 20 def method_missing(name, *args) self.rest_call = name self.scrubbed_params = args.first if respond_to?(name) response_from_redis_or_service(gi_service).body elsif search_respond_to?(name) response_from_redis_or_service(gi_search_service).body elsif lce_respond_to?(name) response_from_redis_or_service(gi_lce_service).body else super end end |
Instance Attribute Details
#rest_call ⇒ Symbol
Returns the GI::Client method to call.
15 16 17 |
# File 'app/models/gids_redis.rb', line 15 def rest_call @rest_call end |
#scrubbed_params ⇒ Hash
Returns the params to be used with the rest_call.
18 19 20 |
# File 'app/models/gids_redis.rb', line 18 def scrubbed_params @scrubbed_params end |
Instance Method Details
#gi_lce_service ⇒ Object (private)
63 64 65 |
# File 'app/models/gids_redis.rb', line 63 def gi_lce_service @lce_service ||= ::GI::Lce::Client.new end |
#gi_search_service ⇒ Object (private)
59 60 61 |
# File 'app/models/gids_redis.rb', line 59 def gi_search_service @search_client ||= ::GI::SearchClient.new end |
#gi_service ⇒ Object (private)
55 56 57 |
# File 'app/models/gids_redis.rb', line 55 def gi_service @client ||= ::GI::Client.new end |
#lce_respond_to?(name) ⇒ Boolean
43 44 45 |
# File 'app/models/gids_redis.rb', line 43 def lce_respond_to?(name) gi_lce_service.respond_to?(name) end |
#respond_to_missing?(name, _include_private) ⇒ Boolean
35 36 37 |
# File 'app/models/gids_redis.rb', line 35 def respond_to_missing?(name, _include_private) gi_service.respond_to?(name) end |
#response_from_redis_or_service(service) ⇒ Object (private)
49 50 51 52 53 |
# File 'app/models/gids_redis.rb', line 49 def response_from_redis_or_service(service) do_cached_with(key: rest_call.to_s + scrubbed_params.to_s) do service.send(rest_call, scrubbed_params) end end |
#search_respond_to?(name) ⇒ Boolean
39 40 41 |
# File 'app/models/gids_redis.rb', line 39 def search_respond_to?(name) gi_search_service.respond_to?(name) end |