Class: ActiveRecord::ModelInheritance::Generators::ModelGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/active_record/model_inheritance/model/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_definition_fileObject



43
44
45
# File 'lib/generators/active_record/model_inheritance/model/model_generator.rb', line 43

def create_definition_file
  template 'definition.erb', ModelInheritance.definitions_path.join("#{table_name}.rb")
end

#generate_modelObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/active_record/model_inheritance/model/model_generator.rb', line 20

def generate_model
  return if skip_generate_model?

  if rails_application?
    invoke 'model',
           [file_path.singularize],
           options.merge(
             fixture_replacement: false,
             migration: false
           )
  else
    template 'model.erb', ModelInheritance.models_path.join("#{file_path.singularize}.rb")
  end
end

#inject_configuration_to_modelObject



35
36
37
38
39
40
41
# File 'lib/generators/active_record/model_inheritance/model/model_generator.rb', line 35

def inject_configuration_to_model
  return if skip_generate_model?

  inject_into_class ModelInheritance.models_path.join("#{file_path.singularize}.rb"), class_name do
    evaluate_template 'model_config.erb'
  end
end