lib/hanami/commands/db/console.rb in hanami-0.8.0 vs lib/hanami/commands/db/console.rb in hanami-0.9.0

- old
+ new

@@ -1,49 +1,33 @@ require 'hanami/utils/class' -require 'hanami/commands/db/abstract' +require 'hanami/commands/command' module Hanami module Commands class DB - class Console < Abstract - attr_reader :name, :env_options + class Console < Command + requires 'model.sql' def initialize(options, name) super(options) - @name = name - @env_options = environment.to_options + @name = name end def start - exec connection_string + exec console.connection_string end private - def config - if name - app_constant = Hanami::Utils::Class.load_from_pattern!(Hanami::Utils::String.new(name).classify) - Hanami::Utils::Class.load_from_pattern!("#{app_constant}::Application").load! - Hanami::Utils::Class.load_from_pattern!("#{app_constant}::Model").configuration - else - Hanami::Model.configuration - end - end + attr_reader :name - def adapter_config - config.adapter_config + def configuration + Hanami::Components['model.configuration'] end - def mapper - config.mapper - end - - def adapter_class - Hanami::Utils::Class.load_from_pattern!(adapter_config.class_name, Hanami::Model::Adapters) - end - - def connection_string - adapter_class.new(mapper, adapter_config.uri).connection_string + def console + require 'hanami/model/sql/console' + Hanami::Model::Sql::Console.new(configuration.url) end end end end end