module RailsHistory::RailsExt::Generator::ClassMethods

Public Instance Methods

invoke(namespace, args = ARGV, config = {}) click to toggle source
Calls superclass method
# 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