Sha256: 8f0168aedb9af1cf3265c0473d3f53b7d14bc9809a4e53208bb88965656a80be
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'rails/generators/active_record' require 'generators/aasm/orm_helpers' module ActiveRecord module Generators class AASMGenerator < ActiveRecord::Generators::Base include AASM::Generators::OrmHelpers argument :column_name, type: :string, default: 'aasm_state' source_root File.expand_path("../templates", __FILE__) def copy_aasm_migration if model_exists? migration_template "migration_existing.rb", "db/migrate/add_aasm_state_to_#{table_name}.rb" else migration_template "migration.rb", "db/migrate/aasm_create_#{table_name}.rb" end end def generate_model invoke "active_record:model", [name], migration: false unless model_exists? end def inject_aasm_content content = model_contents class_path = if namespaced? class_name.to_s.split("::") else [class_name] end inject_into_class(model_path, class_path.last, content) if model_exists? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aasm-4.8.0 | lib/generators/active_record/aasm_generator.rb |
aasm-4.7.0 | lib/generators/active_record/aasm_generator.rb |
aasm-4.6.0 | lib/generators/active_record/aasm_generator.rb |