Module: RTM::Connections

Defined in:
rtm/lib/rtm/connection.rb

Instance Method Summary

Instance Method Details

- (Engine) connect(params = {}, *args)

Connects to a topic map engine using the specificed backend and configuration

Examples:

Connect to Ontopia backend (in memory)

RTM.connect(:backend => :ontopia)

Connect to Ontopia backend (relational database), here: using the H2 adapter

RTM.connect(:backend => :ontopia_rdbms, :config => { :adapter => 'jdbch2', :database => "db-rtm-ontopia"})

Connect to tinyTim backend (in memory)

RTM.connect(:backend => :tinytim)

Connect to Active Record backend (relational database)

RTM.connect(:backend => :activerecord)

Connect to SesameTM backend

RTM.connect(:backend => :sesametm)

Connect to Hatana backend (in memory, with different stores)

RTM.connect(:backend => :hatana)

Parameters:

  • (Hash) params (defaults to: {})

    the options to create the connection with.

Options Hash (params):

  • (Symbol) :backend — default: :ontopia

    the backend

  • (Symbol) :implementation N/A

    @deprecated use :backend instead

  • (Hash) :config — default: nil

    the backend-specific configuration

Returns:

  • (Engine)

    The connection object



25
26
27
28
29
30
31
# File 'rtm/lib/rtm/connection.rb', line 25

def connect(params = {}, *args)
  params ||= {} # this is needed to handle passing nil
  engine = Engine.load!(params[:backend] || params[:implementation])
  connection = engine.connect(params)
  connections[params[:identifier]] = connection if params[:identifier]
  connection
end

- (Hash) connections - (Engine) connections(identifier)

Return all connections or a particular connection.

Overloads:

  • - (Hash) connections

    Returns all registered connections, keyed by their identifiers.

    Returns:

    • (Hash)
  • - (Engine) connections(identifier)

    The connection object

    Parameters:

    • (Symbol) identifier

      of the registered connection

    Returns:

    • (Engine)

      the connection object



40
41
42
43
44
45
46
47
# File 'rtm/lib/rtm/connection.rb', line 40

def connections(*args)
  @connections ||= {}
  if args.size > 0
    @connections[*args]
  else
    @connections
  end
end