Module: LcpRuby::Generators::FormatSupport
- Included in:
- ApiTokensGenerator, AuditingGenerator, BackgroundJobsGenerator, BatchOperationsGenerator, CustomFieldsGenerator, EntityGenerator, ExportGenerator, GapfreeSequencesGenerator, GroupsGenerator, ImportGenerator, InstallAuthGenerator, InstallGenerator, MonitoringGenerator, OidcRoleMappingsGenerator, PagesGenerator, PermissionSourceGenerator, RoleModelGenerator, SavedFiltersGenerator, WorkflowApprovalsGenerator, WorkflowAuditLogGenerator, WorkflowDefinitionGenerator
- Defined in:
- lib/generators/lcp_ruby/format_support.rb
Overview
Shared –format support for generators. Include this module and call ‘include_format_support` in the generator class.
Constant Summary collapse
- VALID_FORMATS =
%w[dsl yaml].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
12 13 14 15 |
# File 'lib/generators/lcp_ruby/format_support.rb', line 12 def self.included(base) base.class_option :format, type: :string, default: "dsl", desc: "Output format: dsl (Ruby DSL) or yaml" end |
Instance Method Details
#validate_format ⇒ Object
17 18 19 20 21 22 |
# File 'lib/generators/lcp_ruby/format_support.rb', line 17 def validate_format fmt = [:format].to_s unless VALID_FORMATS.include?(fmt) raise Thor::Error, "Invalid format '#{fmt}'. Must be one of: #{VALID_FORMATS.join(', ')}" end end |