Class: ActiveRecord::Generators::FreemiumGenerator

Inherits:
Base
  • Object
show all
Includes:
Freemium::Generators::OrmHelpers
Defined in:
lib/generators/active_record/freemium_generator.rb

Instance Method Summary collapse

Methods included from Freemium::Generators::OrmHelpers

#migration_exists?, #migration_path, #model_contents, #model_exists?, #model_path

Instance Method Details

#copy_freemium_migrationObject



12
13
14
# File 'lib/generators/active_record/freemium_generator.rb', line 12

def copy_freemium_migration
  migration_template "migrations/#{table_name}.rb", "db/migrate/freemium_create_#{table_name}"
end

#generate_modelObject



16
17
18
# File 'lib/generators/active_record/freemium_generator.rb', line 16

def generate_model
  invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
end

#inject_freemium_contentObject



20
21
22
23
24
25
# File 'lib/generators/active_record/freemium_generator.rb', line 20

def inject_freemium_content
  inject_into_class(model_path, class_name, model_contents + <<CONTENT) if model_exists?
# Setup accessible (or protected) attributes for your model
include Freemium::#{class_name}
CONTENT
end