class GraphqlMigrateExecution::Strategy
Constants
- METHODS_TO_RENAME
-
These methods conflict with built-in class methods, so when migrating them, prefix them.
Attributes
Public Class Methods
Source
# File lib/graphql_migrate_execution/strategy.rb, line 7 def initialize(action, field_definitions) @action = action @migration = action.migration @filepath = action.filepath @action_method = @migration.action_method @message = action.message @result_source = action.result_source @field_definitions = field_definitions end
Source
# File lib/graphql_migrate_execution/strategy.rb, line 63 def self.prefix_if_necessary(method_name) name_s = method_name.to_s if METHODS_TO_RENAME.include?(name_s) "resolve_#{method_name}" else name_s end end
Source
# File lib/graphql_migrate_execution/strategy.rb, line 47 def self.strategy_name name.split("::").last end
Public Instance Methods
Source
# File lib/graphql_migrate_execution/strategy.rb, line 20 def cleanup(field_definition) end
Source
# File lib/graphql_migrate_execution/strategy.rb, line 17 def migrate(field_definition) end
Source
# File lib/graphql_migrate_execution/strategy.rb, line 23 def run case @action_method when :analyze @message << "\n#{colorize("#{colorize(self.class.strategy_name, self.class.color)} (#{@field_definitions.size})", :BOLD)}:\n" max_path = @field_definitions.map { |f| f.path.size }.max + 2 @field_definitions.each do |field_defn| name = field_defn.path.ljust(max_path) @message << "\n - #{name} (#{field_defn.resolve_mode.inspect} -> #{field_defn.resolve_mode_key.inspect}) @ #{@filepath}:#{field_defn.source_line}" end @message << "\n" when :migrate, :cleanup indent_size = @action.strategy_name_padding + 1 indent = " " * indent_size indent2_size = @action.field_name_padding @message << "\n#{colorize(self.class.strategy_name.ljust(indent_size), self.class.color)}" first = true @field_definitions.each do |field_defn| @message << "#{first ? "" : "#{indent}"}#{field_defn.path.ljust(indent2_size)} @ #{@filepath}:#{field_defn.source_line}\n" first = false public_send(@action_method, field_defn) end end end