Class: GraphQL::Upgrader::MutationDefineToClassTransform
- Defined in:
- lib/graphql/upgrader/member.rb
Overview
Turns {X} = GraphQL::Relay::Mutation.define do
into class {X} < Mutations::BaseMutation
Instance Method Summary collapse
-
#apply(input_text) ⇒ Object
-
#initialize(base_class_name: "Mutations::BaseMutation") ⇒ MutationDefineToClassTransform
constructor
A new instance of MutationDefineToClassTransform.
Methods inherited from Transform
#apply_processor, #normalize_type_expression, #reindent_lines, #trim_lines, #underscorize
Constructor Details
#initialize(base_class_name: "Mutations::BaseMutation") ⇒ MutationDefineToClassTransform
Returns a new instance of MutationDefineToClassTransform
118 119 120 121 |
# File 'lib/graphql/upgrader/member.rb', line 118 def initialize(base_class_name: "Mutations::BaseMutation") @find_pattern = /([a-zA-Z_0-9:]*) = GraphQL::Relay::Mutation.define do/ @replace_pattern = "class \\1 < #{base_class_name}" end |
Instance Method Details
#apply(input_text) ⇒ Object
123 124 125 |
# File 'lib/graphql/upgrader/member.rb', line 123 def apply(input_text) input_text.sub(@find_pattern, @replace_pattern) end |