Class: Eksa::Model
- Inherits:
-
Object
- Object
- Eksa::Model
- Defined in:
- lib/eksa/model.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.database_path ⇒ Object
Returns the value of attribute database_path.
Class Method Summary collapse
Class Attribute Details
.database_path ⇒ Object
Returns the value of attribute database_path.
7 8 9 |
# File 'lib/eksa/model.rb', line 7 def database_path @database_path end |
Class Method Details
.db ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/eksa/model.rb', line 10 def self.db path = database_path || default_db_path db_dir = File.dirname(path) FileUtils.mkdir_p(db_dir) unless Dir.exist?(db_dir) @db ||= SQLite3::Database.new(path) ensure_schema @db end |
.default_db_path ⇒ Object
20 21 22 |
# File 'lib/eksa/model.rb', line 20 def self.default_db_path File.("../../db/eksa_app.db", __dir__) end |
.ensure_schema ⇒ Object
24 25 26 27 28 |
# File 'lib/eksa/model.rb', line 24 def self.ensure_schema return if @schema_initialized @schema_initialized = true setup_schema if respond_to?(:setup_schema) end |