Class: RailsMetricsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/rails_metrics_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



7
8
9
# File 'lib/generators/rails_metrics_generator.rb', line 7

def self.source_root
  @_metrics_source_root ||= File.dirname(__FILE__)
end

Instance Method Details

#add_application_configObject



27
28
29
30
31
32
33
# File 'lib/generators/rails_metrics_generator.rb', line 27

def add_application_config
  inject_into_class "config/application.rb", "Application", <<-CONTENT
  # Set rails metrics store
  config.rails_metrics.set_store = lambda { ::#{class_name} }

CONTENT
end

#add_model_configObject



21
22
23
24
25
# File 'lib/generators/rails_metrics_generator.rb', line 21

def add_model_config
  inject_into_class "app/models/#{file_name}.rb", class_name, <<-CONTENT
include RailsMetrics::ORM::#{Rails::Generators.options[:rails][:orm].to_s.camelize}
CONTENT
end

#copy_public_filesObject



11
12
13
14
# File 'lib/generators/rails_metrics_generator.rb', line 11

def copy_public_files
  directory "../../public", "public", :recursive => true
  exit(0) if options.update?
end

#invoke_modelObject



16
17
18
19
# File 'lib/generators/rails_metrics_generator.rb', line 16

def invoke_model
  invoke "model", [name].concat(migration_columns),
    :timestamps => false, :test_framework => false, :migration => options.migration?
end