mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00

* Add persistence for NoBrainer * Add tests for NoBrainer * Show the ORM version when running the tests * Add a Dockerfile and a docker-compose.yml file allowing to run from anywhere very easily the test suite with `docker-compose run --rm aasm\' * Moves the Mongoid database name definition in the gem loader (avoiding code repetition) * Update the CHANGELOG.md and the README.md files * Add Rails generator for NoBrainer
28 lines
820 B
Ruby
28 lines
820 B
Ruby
require 'rails/generators/named_base'
|
|
require 'generators/aasm/orm_helpers'
|
|
|
|
module NoBrainer
|
|
module Generators
|
|
class AASMGenerator < Rails::Generators::NamedBase
|
|
include AASM::Generators::OrmHelpers
|
|
namespace 'nobrainer:aasm'
|
|
argument :column_name, type: :string, default: 'aasm_state'
|
|
|
|
def generate_model
|
|
invoke 'nobrainer:model', [name] unless model_exists?
|
|
end
|
|
|
|
def inject_aasm_content
|
|
inject_into_file model_path, model_contents, after: "include NoBrainer::Document::Timestamps\n" if model_exists?
|
|
end
|
|
|
|
def inject_field_types
|
|
inject_into_file model_path, migration_data, after: "include NoBrainer::Document::Timestamps\n" if model_exists?
|
|
end
|
|
|
|
def migration_data
|
|
" field :#{column_name}"
|
|
end
|
|
end
|
|
end
|
|
end
|