Class: Pragma::Operation::Base

Inherits:
Trailblazer::Operation
  • Object
show all
Defined in:
lib/pragma/operation/base.rb

Overview

This is the base class all your operations should extend.

Author:

  • Alessandro Desantis

Class Method Summary collapse

Class Method Details

.operation_nameSymbol

Returns the name of this operation.

For instance, if the operation is called API::V1::Post::Operation::Create, returns create.

Returns:

  • (Symbol)


16
17
18
19
20
21
22
23
# File 'lib/pragma/operation/base.rb', line 16

def operation_name
  name.split('::').last
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .downcase
    .to_sym
end