Class: Ork::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/ork/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = :main, options = {}) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
# File 'lib/ork/connection.rb', line 5

def initialize(context = :main, options = {})
  @context = context
  @options = options
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/ork/connection.rb', line 3

def context
  @context
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/ork/connection.rb', line 3

def options
  @options
end

Instance Method Details

#reset!Object



10
11
12
# File 'lib/ork/connection.rb', line 10

def reset!
  threaded[context] = nil
end

#riakObject



20
21
22
# File 'lib/ork/connection.rb', line 20

def riak
  threaded[context] ||= Riak::Client.new(options)
end

#start(context, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/ork/connection.rb', line 14

def start(context, options = {})
  self.context = context
  self.options = options
  self.reset!
end

#threadedObject



24
25
26
# File 'lib/ork/connection.rb', line 24

def threaded
  Thread.current[:ork] ||= {}
end