lib/mutant/mutator.rb in mutant-0.3.0.beta2 vs lib/mutant/mutator.rb in mutant-0.3.0.beta3
- old
+ new
@@ -10,13 +10,13 @@
#
# @return [self]
#
# @api private
#
- def self.each(node, &block)
- return to_enum(__method__, node) unless block_given?
- Registry.lookup(node).new(node, block)
+ def self.each(node, parent=nil, &block)
+ return to_enum(__method__, node, parent) unless block_given?
+ Registry.lookup(node).new(node, parent, block)
self
end
# Register node class handler
@@ -50,23 +50,32 @@
#
# @api private
#
attr_reader :input
+ # Return input
+ #
+ # @return [Object]
+ #
+ # @api private
+ #
+ attr_reader :parent
+
private
# Initialize object
#
# @param [Object] input
+ # @param [Object] parent
# @param [#call(node)] block
#
# @return [undefined]
#
# @api private
#
- def initialize(input, block)
- @input, @block = IceNine.deep_freeze(input), block
+ def initialize(input, parent, block)
+ @input, @parent, @block = input, parent, block
@seen = Set.new
guard(input)
dispatch
end
@@ -171,10 +180,10 @@
# @return [undefined]
#
# @api private
#
def run(mutator)
- mutator.new(input, method(:emit))
+ mutator.new(input, self, method(:emit))
end
# Shortcut to create a new unfrozen duplicate of input
#
# @return [Object]