Sha256: e5a8aacc1e2c294b4efe78522aa928d7aa8715590c2028591dd92c16922e8b65
Contents?: true
Size: 1.71 KB
Versions: 31
Compression:
Stored size: 1.71 KB
Contents
module Pacer module Wrappers class WrappingPipeFunction include com.tinkerpop.pipes.PipeFunction attr_reader :block, :graph, :wrapper, :extensions def initialize(back, block) @block = block if back @graph = back.graph @extensions = back.extensions element_type = back.element_type end @wrapper = WrapperSelector.build graph, element_type, extensions end def arity block.arity end def compute(element) e = wrapper.new graph, element if element block.call e end alias call compute def call_with_args(element, *args) e = wrapper.new graph, element if element block.call e, *args end def wrap_path(path) path.collect do |item| if item.is_a? Pacer::Vertex wrapped = Pacer::Wrappers::VertexWrapper.new graph, item wrapped elsif item.is_a? Pacer::Edge wrapped = Pacer::Wrappers::EdgeWrapper.new graph, item wrapped else item end end end end class UnwrappingPipeFunction include com.tinkerpop.pipes.PipeFunction attr_reader :block def initialize(block) @block = block end def arity block.arity end def compute(element) e = block.call element if e.is_a? ElementWrapper e.element else e end end alias call compute def call_with_args(element, *args) e = block.call element, *args if e.is_a? ElementWrapper e.element else e end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems