Class: AstDB::Database
- Inherits:
-
Object
- Object
- AstDB::Database
- Defined in:
- lib/astdb/models/database.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Database
constructor
A new instance of Database.
- #reload_database ⇒ Object
- #set(value_hash) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Database
Returns a new instance of Database.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/astdb/models/database.rb', line 6 def initialize(opts = {}) @connection = Connection.new host: opts[:host], username: opts[:username], password: opts[:password] @auto_reload = opts[:auto_reload].nil? ? true : opts[:auto_reload] @database = {} reload_database if @auto_reload end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/astdb/models/database.rb', line 4 def connection @connection end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
4 5 6 |
# File 'lib/astdb/models/database.rb', line 4 def hash @hash end |
Instance Method Details
#reload_database ⇒ Object
24 25 26 |
# File 'lib/astdb/models/database.rb', line 24 def reload_database @hash = @connection.fetch_database end |
#set(value_hash) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/astdb/models/database.rb', line 17 def set(value_hash) errors = @connection.set_database_values(value_hash) reload_database if @auto_reload errors end |