Class: Mongoid::Generators::AASMGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
AASM::Generators::OrmHelpers
Defined in:
lib/generators/mongoid/aasm_generator.rb

Instance Method Summary collapse

Methods included from AASM::Generators::OrmHelpers

#model_contents

Instance Method Details

#generate_modelObject


11
12
13
# File 'lib/generators/mongoid/aasm_generator.rb', line 11

def generate_model
  invoke "mongoid:model", [name] unless model_exists?
end

#inject_aasm_contentObject


15
16
17
# File 'lib/generators/mongoid/aasm_generator.rb', line 15

def inject_aasm_content
  inject_into_file model_path, model_contents, after: "include Mongoid::Document\n" if model_exists?
end

#inject_field_typesObject


19
20
21
# File 'lib/generators/mongoid/aasm_generator.rb', line 19

def inject_field_types
  inject_into_file model_path, migration_data, after: "include Mongoid::Document\n" if model_exists?
end

#migration_dataObject


23
24
25
# File 'lib/generators/mongoid/aasm_generator.rb', line 23

def migration_data
  "  field :#{column_name}"
end