Module: Rails::Sh::Rails

Extended by:
Forkable
Defined in:
lib/rails/sh/rails.rb

Class Method Summary collapse

Methods included from Forkable

_invoke, after_fork, before_fork, invoke, run_after_fork, run_before_fork

Methods included from Helpers

#lesspipe

Class Method Details

._invoke(line) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rails/sh/rails.rb', line 16

def _invoke(line)
  reload!
  ARGV.clear
  ARGV.concat line.split(/\s+/)
  puts "\e[42m$ rails #{ARGV.join(" ")}\e[0m"
  require 'rails/commands'
end

.initObject



7
8
9
10
11
12
13
14
# File 'lib/rails/sh/rails.rb', line 7

def init
  before_fork do
    ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base)
  end
  after_fork do
    ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
  end
end

.reload!Object



24
25
26
# File 'lib/rails/sh/rails.rb', line 24

def reload!
  ActionDispatch::Callbacks.new(Proc.new {}).call({})
end

.sub_commandsObject



28
29
30
31
# File 'lib/rails/sh/rails.rb', line 28

def sub_commands
  %w(generate destroy plugin benchmarker profiler
    console server dbconsole application runner)
end