Class: ROM::InfluxDB::Gateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/rom/influxdb/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#connect(uri, options) ⇒ Gateway

InfluxDB gateway interface

Examples:

gateway = ROM::InfluxDB::Gateway.new('influxdb://localhost/rom',
  { username: 'foo', password: 'bar' })

Connects to database via uri passing options

Parameters:

  • uri (String, Symbol)

    connection URI

  • options (Hash)

    connection options



23
24
25
26
# File 'lib/rom/influxdb/gateway.rb', line 23

def initialize(uri, options = {})
  @connection = connect(uri, options)
  @sets = {}
end

Instance Attribute Details

#setsObject (readonly)

Returns the value of attribute sets.



8
9
10
# File 'lib/rom/influxdb/gateway.rb', line 8

def sets
  @sets
end

Instance Method Details

#[](name) ⇒ Dataset

Return dataset with the given name

Parameters:

  • name (String)

    dataset name

Returns:



46
47
48
# File 'lib/rom/influxdb/gateway.rb', line 46

def [](name)
  sets.fetch(name)
end

#command_namespaceObject



62
63
64
# File 'lib/rom/influxdb/gateway.rb', line 62

def command_namespace
  InfluxDB::Commands
end

#dataset(name) ⇒ Dataset

Return dataset with the given name

Parameters:

  • name (String)

    a dataset name

Returns:



35
36
37
# File 'lib/rom/influxdb/gateway.rb', line 35

def dataset(name)
  sets[name] = Dataset.new(name, connection)
end

#dataset?(name) ⇒ Boolean

Check if dataset exists

Parameters:

  • name (String)

    dataset name

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/rom/influxdb/gateway.rb', line 55

def dataset?(name)
  connection.query("select * from #{name} limit 1")
  true
rescue ::InfluxDB::Error
  false
end