Class: ROM::RethinkDB::Gateway
- Inherits:
-
Gateway
- Object
- Gateway
- ROM::RethinkDB::Gateway
- Defined in:
- lib/rom/rethinkdb/gateway.rb
Instance Method Summary collapse
-
#[](name) ⇒ Dataset
Return dataset with the given name.
-
#dataset(name) ⇒ Dataset
Return dataset with the given name.
-
#dataset?(name) ⇒ Boolean
Check if dataset exists.
-
#disconnect ⇒ Object
Disconnect from database.
-
#connect(options) ⇒ Gateway
constructor
RethinkDB gateway interface.
Constructor Details
#connect(options) ⇒ Gateway
RethinkDB gateway interface
19 20 21 22 23 24 |
# File 'lib/rom/rethinkdb/gateway.rb', line 19 def initialize() @datasets = {} @options = @rql = ::RethinkDB::RQL.new @connection = rql.connect() end |
Instance Method Details
#[](name) ⇒ Dataset
Return dataset with the given name
45 46 47 |
# File 'lib/rom/rethinkdb/gateway.rb', line 45 def [](name) datasets[name.to_s] end |
#dataset(name) ⇒ Dataset
Return dataset with the given name
33 34 35 36 |
# File 'lib/rom/rethinkdb/gateway.rb', line 33 def dataset(name) rql.db([:db]).table(name.to_s).run(connection) datasets[name] = Dataset.new(rql.table(name.to_s), rql, connection) end |
#dataset?(name) ⇒ Boolean
Check if dataset exists
54 55 56 57 58 59 |
# File 'lib/rom/rethinkdb/gateway.rb', line 54 def dataset?(name) rql.db([:db]).table(name.to_s).run(connection) true rescue ::RethinkDB::RqlRuntimeError false end |
#disconnect ⇒ Object
Disconnect from database
64 65 66 |
# File 'lib/rom/rethinkdb/gateway.rb', line 64 def disconnect connection.close end |