Class: Satchel::Generators::RegisterGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/satchel/register_generator.rb', line 11

def copy_initializer
  generate('satchel:install')
  text = [
    "Satchel.register('#{class_name}', '#{method_name}') do |activity, context|",
    "  activity.subject = context.#{subject_method}",
    "  activity.user = context.current_user",
    "  activity.activity_type = '#{class_name}##{method_name}'",
    "#  activity.message = 'Specify a custom message if applicable'",
    "end",
    "",
    ""
  ].join("\n")

  inject_into_file('config/initializers/satchel_config.rb', text, before: /\A.*Satchel.register/)
end