Class: FragmentClient
- Inherits:
-
Object
- Object
- FragmentClient
- Defined in:
- lib/fragment_client.rb
Constant Summary collapse
- DEFAULT_URL =
'http://test-eva-fragment-server.herokuapp.com/fragments/full.json?'
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#fragment_server_url ⇒ Object
Returns the value of attribute fragment_server_url.
-
#option_params ⇒ Object
Returns the value of attribute option_params.
Instance Method Summary collapse
- #fetch(section, options = {}) ⇒ Object
-
#initialize(fragment_server_url = DEFAULT_URL, cache = MemoryCache.new) ⇒ FragmentClient
constructor
A new instance of FragmentClient.
Constructor Details
#initialize(fragment_server_url = DEFAULT_URL, cache = MemoryCache.new) ⇒ FragmentClient
Returns a new instance of FragmentClient.
8 9 10 11 |
# File 'lib/fragment_client.rb', line 8 def initialize(fragment_server_url=DEFAULT_URL, cache=MemoryCache.new) self.fragment_server_url = fragment_server_url self.cache = cache end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
5 6 7 |
# File 'lib/fragment_client.rb', line 5 def cache @cache end |
#fragment_server_url ⇒ Object
Returns the value of attribute fragment_server_url.
5 6 7 |
# File 'lib/fragment_client.rb', line 5 def fragment_server_url @fragment_server_url end |
#option_params ⇒ Object
Returns the value of attribute option_params.
5 6 7 |
# File 'lib/fragment_client.rb', line 5 def option_params @option_params end |
Instance Method Details
#fetch(section, options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/fragment_client.rb', line 13 def fetch(section, ={}) set_params() cache.fetch(section + option_params, expires_in: ENV["FRAGMENT_CLIENT_CACHE_TIME"] || 1.hour) { request[section] } end |