Sha256: 29c0127fe4b1131980db5f602dc065dd05075185dfdf5be4f455b508735f7bf3

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

class AuditModelGenerator < Rails::Generator::NamedBase
  def initialize(runtime_args, runtime_options = {})
    runtime_args << 'user' if runtime_args.empty?
    super
    @human_model = runtime_args[0] ? runtime_args[0].underscore : 'user'
  end

  def manifest
    # puts "*** [AuditModelGenerator.manifest] - File.join(File.dirname(__FILE__), '..', '..', 'lib', 'acts_as_audited') = #{File.join(File.dirname(__FILE__), '..', '..', 'lib', 'acts_as_audited')}"
    record do |m|
      m.directory(File.join('app', 'models'))
      m.template('model.rb', "app/models/audit.rb", :assigns => { :human_model => @human_model })
    end
  end

  protected

  def banner
    "Usage: #{$0} audit_model [human_model_name]"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_audited_customized-1.2.1 generators/audit_model/audit_model_generator.rb