Class: Hippo::Command::Console

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hippo/command/console.rb

Instance Method Summary collapse

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hippo/command/console.rb', line 9

def start
    ext = Command.load_current_extension
    require 'irb'
    require 'irb/completion'
    require 'pp'
    require 'faker'
    require 'factory_bot'
    DB.establish_connection
    ActiveRecord::Base.logger = Logger.new STDOUT
    Configuration.apply
    Hippo::Extensions.load_controlling_config
    FactoryBot.definition_file_paths = Hippo::Extensions.map do |ext|
        ext.root_path.join('spec/factories')
    end
    FactoryBot.find_definitions
    Hippo::API::Cable.configure
    MultiTenant.current_tenant = Hippo::Tenant.find_by_slug(
        Hippo.env.development? ? 'dev' : 'system'
    )
    ext.on_dev_console
    Pry::Commands.block_command "tenant", "set current tenant to <slug>" do |slug|
        MultiTenant.current_tenant=Hippo::Tenant.find_by_slug!(slug)
        puts "Current tenant id = #{MultiTenant.current_tenant.id}"
    end
    Pry.start
end