Class: Gaskit::Generators::OperationGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Gaskit::Generators::OperationGenerator
- Defined in:
- lib/generators/gaskit/operation/operation_generator.rb
Overview
A Rails generator for creating new operation classes that inherit from Gaskit::Operation,
Gaskit::Service, or Gaskit::Query, depending on the specified --type option.
This generator supports namespaced operations and places them under app/operations.
Direct Known Subclasses
Constant Summary collapse
- SUPPORTED_TYPES =
%w[base service query].freeze
Instance Method Summary collapse
Instance Method Details
#create_operation_file ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/gaskit/operation/operation_generator.rb', line 38 def create_operation_file validate_type! subdir = case ["type"] when "service" then "services" when "query" then "queries" else "operations" end template "operation.rb.tt", File.join("app", subdir, class_path, "#{file_name}.rb") end |
#validate_type! ⇒ Object
32 33 34 35 36 |
# File 'lib/generators/gaskit/operation/operation_generator.rb', line 32 def validate_type! return if SUPPORTED_TYPES.include?(["type"]) raise ArgumentError, "Invalid type: #{options["type"]}. Supported types are: #{SUPPORTED_TYPES.join(", ")}" end |