Class: RailsMetricsGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RailsMetricsGenerator
- Defined in:
- lib/generators/rails_metrics_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_application_config ⇒ Object
- #add_model_config ⇒ Object
- #copy_public_files ⇒ Object
- #invoke_model ⇒ Object
Class Method Details
.source_root ⇒ Object
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_config ⇒ Object
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_config ⇒ Object
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.[:rails][:orm].to_s.camelize} CONTENT end |
#copy_public_files ⇒ Object
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 .update? end |
#invoke_model ⇒ Object
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 => .migration? end |