module Trailblazer::Generator::Macro
Constants
- ERROR_INVALID_CLASS_NAME
Plase, keep error codes sorted alphabetically
- REGEXP
Public Class Methods
Failure()
click to toggle source
# File lib/trailblazer/generator/macro.rb, line 28 def self.Failure() step = ->(input, options) do puts "Error: " + options['failure_message'] options['error_code'] ? exit(options['error_code']) : exit(1) end [ step, name: "failure" ] end
Output()
click to toggle source
# File lib/trailblazer/generator/macro.rb, line 20 def self.Output() step = ->(input, options) do Trailblazer::Generator::Output.new(path: options['path'], content: options['content']).save end [ step, name: "output" ] end
ValidateClassName()
click to toggle source
# File lib/trailblazer/generator/macro.rb, line 6 def self.ValidateClassName() step = ->(input, options) do if options["params"][:name].match REGEXP true else options['failure_message'] = 'You provided an invalid class name' options['error_code'] = ERROR_INVALID_CLASS_NAME false end end [ step, name: "validate_class_name" ] end