Class: TypedOperationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/typed_operation_generator.rb

Overview

Rails generator for creating new typed operation files and their tests.

Instance Method Summary collapse

Instance Method Details

#generate_operationObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/typed_operation_generator.rb', line 11

def generate_operation
  source_root = self.class.source_root
  operation_path = options[:path]

  template(
    File.join(source_root, "operation.rb"),
    File.join(operation_path, "#{file_name}.rb")
  )
  template(
    File.join(source_root, "operation_test.rb"),
    File.join("test/", operation_path.gsub(/\Aapp\//, ""), "#{file_name}_test.rb")
  )
end