Class: Apollo::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/apollo/instance.rb

Overview

A copy of Apollo’s base module class methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Instance

Returns a new instance of Instance.



10
11
12
# File 'lib/apollo/instance.rb', line 10

def initialize(config = nil)
  self.configuration = config || Configuration.new
end

Instance Attribute Details

#clientObject



14
15
16
# File 'lib/apollo/instance.rb', line 14

def client
  @client ||= Client.new(configuration)
end

#configurationObject

See Apollo::Configuration



8
9
10
# File 'lib/apollo/instance.rb', line 8

def configuration
  @configuration
end

Instance Method Details

#configure {|configuration| ... } ⇒ Object

Yields:



18
19
20
21
22
# File 'lib/apollo/instance.rb', line 18

def configure
  yield(configuration) if block_given?
  self.client = Client.new(configuration)
  client
end

#fetch(key, opts = {}) ⇒ Object



24
25
26
27
# File 'lib/apollo/instance.rb', line 24

def fetch(key, opts = {})
  opts[:disable_cache] = false unless opts.key?(:disable_cache)
  client.fetch(key, opts[:disable_cache])
end