Module: Transpec::Syntax::Mixin::AnyInstanceBlock

Extended by:
ActiveSupport::Concern
Includes:
Send
Included in:
MessagingHost
Defined in:
lib/transpec/syntax/mixin/any_instance_block.rb

Defined Under Namespace

Classes: MonkeyPatchRecordBuilder, RecordBuilder

Instance Method Summary collapse

Methods included from Send

#arg_node, #arg_nodes, #arg_range, #args_range, #method_name, #parentheses_range, #range_after_arg, #range_in_between_receiver_and_selector, #range_in_between_selector_and_arg, #receiver_node, #receiver_range, #selector_range

Methods included from Send::TargetDetection

#conversion_target?, #dynamic_analysis_target?

Instance Method Details

#add_receiver_arg_to_any_instance_implementation_block!Object



21
22
23
24
25
# File 'lib/transpec/syntax/mixin/any_instance_block.rb', line 21

def add_receiver_arg_to_any_instance_implementation_block!
  return unless need_to_add_receiver_arg_to_any_instance_implementation_block?
  insert_before(any_instance_block_first_arg_node.loc.expression, 'instance, ')
  true
end

#need_to_add_receiver_arg_to_any_instance_implementation_block?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/transpec/syntax/mixin/any_instance_block.rb', line 14

def need_to_add_receiver_arg_to_any_instance_implementation_block?
  first_arg_node = any_instance_block_first_arg_node
  return false unless first_arg_node
  first_arg_name = first_arg_node.children.first
  first_arg_name != :instance
end