Class: MetaCommit::Extension::RubySupport::Diffs::InitializeChanged

Inherits:
Diff
  • Object
show all
Defined in:
lib/meta_commit_ruby_support/diffs/initialize_changed.rb

Constant Summary collapse

INITIALIZE_METHOD_NAME =
'initialize'

Constants inherited from Diff

Diff::SUPPORTED_PARSERS

Instance Method Summary collapse

Methods inherited from Diff

#inspect, #supports_parser?, #to_s, #type_addition?, #type_deletion?, #type_replace?

Methods included from Helpers::ContextualAstAccessor

#contextual_ast_has_target_node, #is_in_context_of_class?, #is_in_context_of_method?, #is_in_context_of_module?, #is_name_of_class?, #is_name_of_module?, #name_of_context_class, #name_of_context_method, #name_of_context_module, #path_to_component

Instance Method Details

#string_representationObject



14
15
16
# File 'lib/meta_commit_ruby_support/diffs/initialize_changed.rb', line 14

def string_representation
  "change initialization of #{path_to_component(change_context.new_contextual_ast, 0)}"
end

#supports_change(context) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/meta_commit_ruby_support/diffs/initialize_changed.rb', line 5

def supports_change(context)
  context.type == MetaCommit::Extension::RubySupport::Diffs::Diff::TYPE_REPLACE &&
      contextual_ast_has_target_node(context.old_contextual_ast) &&
      contextual_ast_has_target_node(context.new_contextual_ast) &&
      is_in_context_of_method?(context.old_contextual_ast) &&
      is_in_context_of_method?(context.new_contextual_ast) &&
      name_of_context_method(context.old_contextual_ast) == INITIALIZE_METHOD_NAME && name_of_context_method(context.new_contextual_ast) == INITIALIZE_METHOD_NAME
end