Class: Jinx::CopyVisitor
- Inherits:
-
MergeVisitor
- Object
- Visitor
- ReferenceVisitor
- MatchVisitor
- MergeVisitor
- Jinx::CopyVisitor
- Defined in:
- lib/jinx/resource/copy_visitor.rb
Overview
A CopyVisitor copies a domain object’s visitable attributes transitive closure.
Constant Summary
Constants inherited from MatchVisitor
Instance Attribute Summary
Attributes inherited from MatchVisitor
Attributes inherited from Visitor
Instance Method Summary collapse
-
#initialize(opts = nil) {|obj| ... } ⇒ CopyVisitor
constructor
Creates a new CopyVisitor with the options described in MergeVisitor#initialize.
- #match(sources, targets, from = nil, property = nil) ⇒ Object
-
#visit(source) ⇒ Resource
Copies the given source domain object’s reference graph.
Methods inherited from MergeVisitor
Methods inherited from MatchVisitor
#add_match, #copy_unmatched, #identifier_match, #match_for, #match_for_visited, #match_reference, #match_references, #visit_matched
Methods inherited from ReferenceVisitor
Methods inherited from Visitor
#clear, #current, #cyclic_nodes, #depth_first?, #filter, #from, #node_children, #root, #sync, #to_enum, #visit_children, #visit_node_and_children, #visit_recursive, #visit_root, #visited?
Constructor Details
#initialize(opts = nil) {|obj| ... } ⇒ CopyVisitor
Creates a new CopyVisitor with the options described in MergeVisitor#initialize. The default :copier option is Resource#copy.
15 16 17 18 19 20 21 |
# File 'lib/jinx/resource/copy_visitor.rb', line 15 def initialize(opts=nil) opts = Options.to_hash(opts) opts[:copier] ||= Proc.new { |src| src.copy } # no match forces a copy opts[:matcher] = self super end |
Instance Method Details
#match(sources, targets, from = nil, property = nil) ⇒ Object
32 33 34 |
# File 'lib/jinx/resource/copy_visitor.rb', line 32 def match(sources, targets, from=nil, property=nil) Hash::EMPTY_HASH end |
#visit(source) ⇒ Resource
Copies the given source domain object’s reference graph.
27 28 29 30 |
# File 'lib/jinx/resource/copy_visitor.rb', line 27 def visit(source) target = @copier.call(source) super(source, target) end |