Module: RailsHistory::RailsExt::Generator::ClassMethods

Defined in:
lib/rails_history.rb

Instance Method Summary collapse

Instance Method Details

#invoke(namespace, args = ARGV, config = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_history.rb', line 11

def invoke(namespace, args = ARGV, config = {})
  super

  history_file_path = Rails.root.join('.rails_history')
  command = [].tap do |a|
    a << 'rails'

    if config[:behavior] == :revoke
      a << 'destroy'
    else
      a << 'generate'
    end

    a << namespace
    a << args
  end.join(' ')

  file = File.open(history_file_path, 'a')
  file.puts(command)
end