Class: OrientdbClient::Client
- Inherits:
-
Object
- Object
- OrientdbClient::Client
- Extended by:
- Forwardable
- Defined in:
- lib/orientdb_client.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
Instance Method Summary collapse
- #alter_property(class_name, property_name, field, value) ⇒ Object
- #command(sql) ⇒ Object
- #connect(username:, password:, db:) ⇒ Object
- #connected? ⇒ Boolean
- #create_class(name, options = {}) ⇒ Object
- #create_database(name, storage, type, options = {}) ⇒ Object
- #create_property(class_name, property_name, type, options = {}) ⇒ Object
- #database ⇒ Object
- #database_exists?(name) ⇒ Boolean
- #debug=(val) ⇒ Object
- #delete_database(name, options = {}) ⇒ Object
- #disconnect ⇒ Object
- #drop_class(name) ⇒ Object
- #get_class(name) ⇒ Object
- #get_database(name, options = {}) ⇒ Object
- #has_class?(name) ⇒ Boolean
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #list_databases ⇒ Object
- #query(sql, options = {}) ⇒ Object
- #query_unparsed(sql, options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/orientdb_client.rb', line 26 def initialize() = { host: 'localhost', port: '2480' }.merge() @host = [:host] @port = [:port] adapter_klass = if [:adapter] HttpAdapters.const_get([:adapter]) else HttpAdapters::TyphoeusAdapter end @instrumenter = [:instrumenter] || Instrumenters::Noop @http_client = adapter_klass.new(timeout: [:timeout]) @node = Node.new(host: @host, port: @port, http_client: @http_client, client: self) @connected = false self end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
22 23 24 |
# File 'lib/orientdb_client.rb', line 22 def http_client @http_client end |
Instance Method Details
#alter_property(class_name, property_name, field, value) ⇒ Object
85 86 87 |
# File 'lib/orientdb_client.rb', line 85 def alter_property(class_name, property_name, field, value) @node.alter_property(class_name, property_name, field, value) end |
#command(sql) ⇒ Object
121 122 123 |
# File 'lib/orientdb_client.rb', line 121 def command(sql) @node.command(sql) end |
#connect(username:, password:, db:) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/orientdb_client.rb', line 45 def connect(username:, password:, db:) raise ClientError.new('Already connected') if connected? @username = username @password = password @db = db @http_client.username = @username @http_client.password = @password @node.connect(@db) end |
#connected? ⇒ Boolean
125 126 127 |
# File 'lib/orientdb_client.rb', line 125 def connected? @node.connected? end |
#create_class(name, options = {}) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/orientdb_client.rb', line 73 def create_class(name, = {}) response = @node.create_class(name, ) if block_given? yield ClassConfigurator.new(name, @node) end response end |
#create_database(name, storage, type, options = {}) ⇒ Object
64 65 66 67 |
# File 'lib/orientdb_client.rb', line 64 def create_database(name, storage, type, = {}) raise ArgumentError, "Invalid database type: #{type}" unless DATABASE_TYPES.include?(type) @node.create_database(name, storage, type, ) end |
#create_property(class_name, property_name, type, options = {}) ⇒ Object
81 82 83 |
# File 'lib/orientdb_client.rb', line 81 def create_property(class_name, property_name, type, = {}) @node.create_property(class_name, property_name, type, ) end |
#database ⇒ Object
129 130 131 |
# File 'lib/orientdb_client.rb', line 129 def database @node.database end |
#database_exists?(name) ⇒ Boolean
105 106 107 |
# File 'lib/orientdb_client.rb', line 105 def database_exists?(name) list_databases.include?(name) end |
#debug=(val) ⇒ Object
133 134 135 |
# File 'lib/orientdb_client.rb', line 133 def debug=(val) @node.debug = val end |
#delete_database(name, options = {}) ⇒ Object
69 70 71 |
# File 'lib/orientdb_client.rb', line 69 def delete_database(name, = {}) @node.delete_database(name, ) end |
#disconnect ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/orientdb_client.rb', line 55 def disconnect raise ClientError.new('Not connected') unless connected? @username = nil @password = nil @db = nil @http_client.reset_credentials @node.disconnect end |
#drop_class(name) ⇒ Object
97 98 99 |
# File 'lib/orientdb_client.rb', line 97 def drop_class(name) @node.drop_class(name) end |
#get_class(name) ⇒ Object
89 90 91 |
# File 'lib/orientdb_client.rb', line 89 def get_class(name) @node.get_class(name) end |
#get_database(name, options = {}) ⇒ Object
101 102 103 |
# File 'lib/orientdb_client.rb', line 101 def get_database(name, = {}) @node.get_database(name, ) end |
#has_class?(name) ⇒ Boolean
93 94 95 |
# File 'lib/orientdb_client.rb', line 93 def has_class?(name) @node.has_class?(name) end |
#list_databases ⇒ Object
109 110 111 |
# File 'lib/orientdb_client.rb', line 109 def list_databases @node.list_databases end |
#query(sql, options = {}) ⇒ Object
113 114 115 |
# File 'lib/orientdb_client.rb', line 113 def query(sql, = {}) @node.query(sql, ) end |
#query_unparsed(sql, options = {}) ⇒ Object
117 118 119 |
# File 'lib/orientdb_client.rb', line 117 def query_unparsed(sql, = {}) @node.query_unparsed(sql, ) end |