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
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#fragment_server_url ⇒ Object
Returns the value of attribute fragment_server_url.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#option_params ⇒ Object
Returns the value of attribute option_params.
Instance Method Summary collapse
- #fetch(section, options = {}) ⇒ Object
-
#initialize(app_name, fragment_server_url = DEFAULT_URL, cache = MemoryCache.new, logger = default_logger) ⇒ FragmentClient
constructor
A new instance of FragmentClient.
Constructor Details
#initialize(app_name, fragment_server_url = DEFAULT_URL, cache = MemoryCache.new, logger = default_logger) ⇒ FragmentClient
Returns a new instance of FragmentClient.
10 11 12 13 14 15 |
# File 'lib/fragment_client.rb', line 10 def initialize(app_name, fragment_server_url=DEFAULT_URL, cache=MemoryCache.new, logger=default_logger) self.app_name = app_name self.fragment_server_url = fragment_server_url self.cache = cache self.logger = logger end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
6 7 8 |
# File 'lib/fragment_client.rb', line 6 def app_name @app_name end |
#cache ⇒ Object
Returns the value of attribute cache.
6 7 8 |
# File 'lib/fragment_client.rb', line 6 def cache @cache end |
#fragment_server_url ⇒ Object
Returns the value of attribute fragment_server_url.
6 7 8 |
# File 'lib/fragment_client.rb', line 6 def fragment_server_url @fragment_server_url end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/fragment_client.rb', line 6 def logger @logger end |
#option_params ⇒ Object
Returns the value of attribute option_params.
6 7 8 |
# File 'lib/fragment_client.rb', line 6 def option_params @option_params end |
Instance Method Details
#fetch(section, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/fragment_client.rb', line 17 def fetch(section, ={}) set_params() log(section) cache.fetch(section.to_s + option_params, expires_in: ENV["FRAGMENT_CLIENT_CACHE_TIME"].to_i || 1.hour) do request[section] end end |