Class: FragmentClient

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#cacheObject

Returns the value of attribute cache.



4
5
6
# File 'lib/fragment_client/fragment_client.rb', line 4

def cache
  @cache
end

#fragment_server_urlObject

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_paramsObject

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, options={})
  set_params(options)
  cache.fetch(section + option_params) { request[section] }
end