Class: Mylk::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mylk/base.rb

Overview

Base class for SurrealDB clients

Direct Known Subclasses

HTTP, WebSocket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Base

Parameters:

uri: String
  The URI of the SurrealDB server
  Example: "http://user:password@localhost:8080/namespace/database"


12
13
14
# File 'lib/mylk/base.rb', line 12

def initialize(uri)
  parse_connection_params(uri)
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



6
7
8
# File 'lib/mylk/base.rb', line 6

def database
  @database
end

#namespaceObject

Returns the value of attribute namespace.



6
7
8
# File 'lib/mylk/base.rb', line 6

def namespace
  @namespace
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/mylk/base.rb', line 6

def password
  @password
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/mylk/base.rb', line 6

def uri
  @uri
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/mylk/base.rb', line 6

def username
  @username
end

Instance Method Details

#connectObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/mylk/base.rb', line 16

def connect
  raise NotImplementedError
end

#connected?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/mylk/base.rb', line 24

def connected?
  !!@connected
end

#disconnectObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/mylk/base.rb', line 20

def disconnect
  raise NotImplementedError
end

#disconnected?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mylk/base.rb', line 28

def disconnected?
  !connected?
end