Class: Guacamole::Generators::CallbacksGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/guacamole/callbacks/callbacks_generator.rb

Instance Method Summary collapse

Methods inherited from Base

source_root

Instance Method Details

#create_callback_fileObject



14
15
16
17
18
19
20
21
# File 'lib/rails/generators/guacamole/callbacks/callbacks_generator.rb', line 14

def create_callback_file
  model_file_name = (options[:model_class] || class_name).underscore
  inject_into_file "app/models/#{model_file_name}.rb",
    "\n\n  callbacks :#{class_name.underscore}_callbacks",
    after: 'include Guacamole::Model'

  template 'callbacks.rb.tt', File.join('app/callbacks', class_path, "#{file_name}_callbacks.rb")
end