Class: Apolo::Notifiers::Sqlite
- Inherits:
-
Object
- Object
- Apolo::Notifiers::Sqlite
- Defined in:
- lib/apolo/notifiers/sqlite.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sqlite
constructor
A new instance of Sqlite.
- #notify(monitor, message, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sqlite
Returns a new instance of Sqlite.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/apolo/notifiers/sqlite.rb', line 8 def initialize( = {}) @db_name = [:db_name] @db_table = [:db_table] unless @db_name && @db_table raise ArgumentError, 'You need to set :db_name and :db_table to use sqlite notify.' end @db = Sequel.sqlite database: @db_name @db.create_table?(@db_table.to_sym) do primary_key :id DateTime :created_at String :monitor String :message Float :value end end |
Instance Method Details
#notify(monitor, message, value) ⇒ Object
27 28 29 30 |
# File 'lib/apolo/notifiers/sqlite.rb', line 27 def notify(monitor, , value) @db[@db_table.to_sym].insert(created_at: DateTime.now, monitor: monitor,\ message: , value: value) end |