Class: ActiveRecord::WorkflowModelGenerator
- Inherits:
-
Generators::ModelGenerator
- Object
- Generators::ModelGenerator
- ActiveRecord::WorkflowModelGenerator
- Includes:
- OrmHelpers, OscMacheteRails::JobHelpers
- Defined in:
- lib/generators/active_record/workflow_model_generator.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
add a new attribute to the generator the workflow needs to know what the job model is to render the template properly.
Instance Method Summary collapse
-
#create_model_file ⇒ Object
overrides original ModelGenerator#create_model_file to make a workflow_model instead of a model since we are inheriting from ModelGenerator, we get the tests and all the other good stuff.
-
#initialize(args, *options) ⇒ WorkflowModelGenerator
constructor
jobs is a new attribute type, like “references”, so we can let the user specify the corresponding job model.
Constructor Details
#initialize(args, *options) ⇒ WorkflowModelGenerator
jobs is a new attribute type, like “references”, so we can let the user specify the corresponding job model. This attribute is used in the workflow_model.rb template file. i.e.
rails g osc_machete_rails:workflow_model Container name:string container_job:jobs
20 21 22 23 |
# File 'lib/generators/active_record/workflow_model_generator.rb', line 20 def initialize(args, *) @job = parse_job!(args) super end |
Instance Attribute Details
#job ⇒ Object (readonly)
add a new attribute to the generator the workflow needs to know what the job model is to render the template properly
13 14 15 |
# File 'lib/generators/active_record/workflow_model_generator.rb', line 13 def job @job end |
Instance Method Details
#create_model_file ⇒ Object
overrides original ModelGenerator#create_model_file to make a workflow_model instead of a model since we are inheriting from ModelGenerator, we get the tests and all the other good stuff
27 28 29 |
# File 'lib/generators/active_record/workflow_model_generator.rb', line 27 def create_model_file template 'workflow_model.rb', File.join('app/models', class_path, "#{file_name}.rb") end |