Class: FragmentClient
- Inherits:
-
Object
- Object
- FragmentClient
- Defined in:
- lib/fragment_client/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.
7 8 9 10 |
# File 'lib/fragment_client/fragment_client.rb', line 7 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.
4 5 6 |
# File 'lib/fragment_client/fragment_client.rb', line 4 def cache @cache end |
#fragment_server_url ⇒ Object
Returns the value of attribute fragment_server_url.
4 5 6 |
# File 'lib/fragment_client/fragment_client.rb', line 4 def fragment_server_url @fragment_server_url end |
#option_params ⇒ Object
Returns the value of attribute option_params.
4 5 6 |
# File 'lib/fragment_client/fragment_client.rb', line 4 def option_params @option_params end |
Instance Method Details
#fetch(section, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/fragment_client/fragment_client.rb', line 12 def fetch(section, ={}) set_params() cache.fetch(section + option_params) { request[section] } end |