Class: Kangaru::Database
- Inherits:
-
Object
- Object
- Kangaru::Database
- Extended by:
- Forwardable
- Includes:
- Attributable
- Defined in:
- lib/kangaru/database.rb
Constant Summary collapse
- PLUGINS =
%i[ enum timestamps ].freeze
Instance Attribute Summary collapse
-
#adaptor ⇒ Object
Returns the value of attribute adaptor.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#migration_path ⇒ Object
Returns the value of attribute migration_path.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Methods included from Attributable
Methods included from Concern
#append_features, #class_methods, #included
Instance Attribute Details
#adaptor ⇒ Object
Returns the value of attribute adaptor.
12 13 14 |
# File 'lib/kangaru/database.rb', line 12 def adaptor @adaptor end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
14 15 16 |
# File 'lib/kangaru/database.rb', line 14 def handler @handler end |
#migration_path ⇒ Object
Returns the value of attribute migration_path.
12 13 14 |
# File 'lib/kangaru/database.rb', line 12 def migration_path @migration_path end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/kangaru/database.rb', line 12 def path @path end |
Instance Method Details
#migrate! ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/kangaru/database.rb', line 25 def migrate! return unless handler return unless migrations_exist? Sequel.extension(:migration) Sequel::Migrator.run(handler, migration_path) end |
#setup! ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/kangaru/database.rb', line 16 def setup! raise "adaptor can't be blank" if adaptor.nil? @handler = case adaptor when :sqlite then setup_sqlite! else raise "invalid adaptor '#{adaptor}'" end end |