class Satchel::Generators::RegisterGenerator

Public Instance Methods

copy_initializer() click to toggle source
# 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