Class: Bones::RPC::Context

Inherits:
Object
  • Object
show all
Includes:
Readable
Defined in:
lib/bones/rpc/context.rb

Overview

The class for interacting with a MongoDB database. One only interacts with this class indirectly through a session.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Context

Initialize the database.

Examples:

Initialize a database object.

Database.new(session, :artists)

Parameters:

  • session (Session)

    The session.

  • name (String, Symbol)

    The name of the database.

Since:

  • 1.0.0


25
26
27
# File 'lib/bones/rpc/context.rb', line 25

def initialize(session)
  @session = session
end

Instance Attribute Details

#sessionObject

Since:

  • 1.0.0


14
15
16
# File 'lib/bones/rpc/context.rb', line 14

def session
  @session
end

Instance Method Details

#notify(method, params) ⇒ Object

Since:

  • 1.0.0


29
30
31
32
33
# File 'lib/bones/rpc/context.rb', line 29

def notify(method, params)
  read_preference.with_node(cluster) do |node|
    node.notify(method, params)
  end
end

#request(method, params) ⇒ Object

Since:

  • 1.0.0


35
36
37
38
39
# File 'lib/bones/rpc/context.rb', line 35

def request(method, params)
  read_preference.with_node(cluster) do |node|
    node.request(method, params)
  end
end

#synchronizeObject

Since:

  • 1.0.0


41
42
43
44
45
# File 'lib/bones/rpc/context.rb', line 41

def synchronize
  read_preference.with_node(cluster) do |node|
    node.synchronize
  end
end