Class: InfluxORM::Connection
- Inherits:
-
Object
- Object
- InfluxORM::Connection
- Defined in:
- lib/influx_orm/connection.rb
Instance Attribute Summary collapse
-
#client_config ⇒ Object
readonly
Returns the value of attribute client_config.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #db ⇒ Object
- #import(data) ⇒ Object
-
#initialize(options, configuration) ⇒ Connection
constructor
A new instance of Connection.
- #insert(table_name, point) ⇒ Object
- #query(sql) ⇒ Object
Constructor Details
#initialize(options, configuration) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 |
# File 'lib/influx_orm/connection.rb', line 5 def initialize(, configuration) @config = .with_indifferent_access @configuration = configuration end |
Instance Attribute Details
#client_config ⇒ Object (readonly)
Returns the value of attribute client_config.
3 4 5 |
# File 'lib/influx_orm/connection.rb', line 3 def client_config @client_config end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/influx_orm/connection.rb', line 3 def config @config end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/influx_orm/connection.rb', line 3 def configuration @configuration end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
3 4 5 |
# File 'lib/influx_orm/connection.rb', line 3 def database @database end |
Instance Method Details
#db ⇒ Object
10 11 12 |
# File 'lib/influx_orm/connection.rb', line 10 def db @db ||= InfluxDB::Client.new(config) end |
#import(data) ⇒ Object
22 23 24 |
# File 'lib/influx_orm/connection.rb', line 22 def import(data) log("IMPORT #{data}") { db.write_points(data) } end |
#insert(table_name, point) ⇒ Object
18 19 20 |
# File 'lib/influx_orm/connection.rb', line 18 def insert(table_name, point) log("INSERT to #{table_name}: #{point}") { db.write_point(table_name, point) } end |
#query(sql) ⇒ Object
14 15 16 |
# File 'lib/influx_orm/connection.rb', line 14 def query(sql) log(sql) { db.query(sql) } end |