Class: ActivityNotification::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/activity_notification/install_generator.rb

Overview

Install generator to copy initializer and locale file to rails application.

Examples:

Run install generator

rails generate activity_notification:install

Instance Method Summary collapse

Instance Method Details

#copy_initializer ⇒ Object

Copies initializer file in application directory



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/activity_notification/install_generator.rb', line 15

def copy_initializer
  #TODO suport other orm e.g. mongoid
  unless options[:orm] == :active_record
    raise TypeError, "    Currently ActivityNotification is only supported with Active Record ORM.\n\n    Be sure to have an Active Record ORM loaded in your\n    app or configure your own at `config/application.rb`.\n\n      config.generators do |g|\n        g.orm :active_record\n      end\n    ERROR\n  end\n\n  template \"activity_notification.rb\", \"config/initializers/activity_notification.rb\"\nend\n".strip_heredoc

#copy_locale ⇒ Object

Copies locale files in application directory



34
35
36
# File 'lib/generators/activity_notification/install_generator.rb', line 34

def copy_locale
  template "locales/en.yml", "config/locales/activity_notification.en.yml"
end

#show_readme ⇒ Object

Shows readme to console



39
40
41
# File 'lib/generators/activity_notification/install_generator.rb', line 39

def show_readme
  readme "README" if behavior == :invoke
end