Class: Mxrb::Scaffold::Generator
- Inherits:
-
Object
- Object
- Mxrb::Scaffold::Generator
- Includes:
- Recipes
- Defined in:
- lib/mxrb/scaffold/generator.rb
Overview
Creates conventional Ruby-first artifacts and connects missing aggregators. rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: Result
Constant Summary collapse
- IDENTIFIER =
/\A[A-Za-z][A-Za-z0-9_]*\z/- RESERVED_ENTITY_NAMES =
%w[Owner ChangedBy CreatedDate ChangedDate].freeze
- PAGE_CHAINS =
%w[page:microflow page:nanoflow page:nanoflow:microflow].freeze
- LAYER_AGGREGATORS =
{ 'domain' => 'model.rb', 'application' => 'application.rb', 'presentation' => 'presentation.rb', 'infrastructure' => 'infrastructure.rb' }.freeze
Constants included from Recipes
Recipes::INFRASTRUCTURE, Recipes::SIMPLE
Instance Method Summary collapse
-
#initialize(kind, name = nil, target: Dir.pwd, dry_run: false, **page_options) ⇒ Generator
constructor
A new instance of Generator.
- #scaffold ⇒ Object
Constructor Details
#initialize(kind, name = nil, target: Dir.pwd, dry_run: false, **page_options) ⇒ Generator
Returns a new instance of Generator.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mxrb/scaffold/generator.rb', line 21 def initialize(kind, name = nil, target: Dir.pwd, dry_run: false, **) @kind = kind.to_sym @name = name.to_s @root = File.(target) @transaction = Transaction.new @dry_run = dry_run @page_chain = .delete(:page_chain) @page_template = .delete(:page_template) raise ArgumentError, "unknown generator options: #{.keys.join(', ')}" unless .empty? end |
Instance Method Details
#scaffold ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/mxrb/scaffold/generator.rb', line 33 def scaffold send("scaffold_#{@kind}") registry = stage_registry unless @dry_run @transaction.commit unless @dry_run Result.new( @root, visible(@transaction.created, registry), visible(@transaction.updated, registry), @kind, @name, @dry_run ) end |