Class: Dolphin::DataStore::BaseRdb
- Inherits:
-
Object
- Object
- Dolphin::DataStore::BaseRdb
- Defined in:
- lib/dolphin/data_stores/base_rdb.rb
Direct Known Subclasses
Constant Summary collapse
Instance Method Summary collapse
- #closed? ⇒ Boolean
- #connect_path ⇒ Object
- #current_database ⇒ Object
- #delete_notification(notification) ⇒ Object
- #get_event(params) ⇒ Object
- #get_notification(id) ⇒ Object
-
#initialize(config) ⇒ BaseRdb
constructor
A new instance of BaseRdb.
- #put_event(event) ⇒ Object
- #put_notification(id, methods) ⇒ Object
Constructor Details
#initialize(config) ⇒ BaseRdb
Returns a new instance of BaseRdb.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 5 def initialize(config) @adapter = config[:adapter] @host = config[:host] @user = config[:user] @password = config[:password] @database = config[:database] # Set timezone to UTC Sequel.default_timezone = :utc end |
Instance Method Details
#closed? ⇒ Boolean
20 21 22 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 20 def closed? @connection.nil? end |
#connect_path ⇒ Object
51 52 53 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 51 def connect_path "#{@adapter}://#{@host}/#{@database}?user=#{@user}&password=#{@password}" end |
#current_database ⇒ Object
16 17 18 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 16 def current_database Sequel.connect(connect_path) end |
#delete_notification(notification) ⇒ Object
46 47 48 49 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 46 def delete_notification(notification) n = Dolphin::Models::Rdb::Notification.new(ORM::Notification) n.delete(notification) end |
#get_event(params) ⇒ Object
36 37 38 39 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 36 def get_event(params) e = Dolphin::Models::Rdb::Event.new(ORM::Event) e.get(params) end |
#get_notification(id) ⇒ Object
26 27 28 29 |
# File 'lib/dolphin/data_stores/base_rdb.rb', line 26 def get_notification(id) n = Dolphin::Models::Rdb::Notification.new(ORM::Notification) n.get(id) end |