Sha256: 1446cd89e898833450d5337bc71372b1e0f83faa00d7e2833f548c53acbecd68

Contents?: true

Size: 1.56 KB

Versions: 31

Compression:

Stored size: 1.56 KB

Contents

module Pacer::Wrappers
  class WrapperSelector
    import com.tinkerpop.blueprints.Vertex
    import com.tinkerpop.blueprints.Edge

    def self.build(graph, element_type = nil, extensions = [])
      if graph
        if element_type == :vertex
          graph.base_vertex_wrapper.wrapper_for extensions
        elsif element_type == :edge
          graph.base_edge_wrapper.wrapper_for extensions
        else
          new extensions
        end
      else
        if element_type == :vertex
          Pacer::Wrappers::VertexWrapper.wrapper_for extensions
        elsif element_type == :edge
          Pacer::Wrappers::EdgeWrapper.wrapper_for extensions
        else
          new extensions
        end
      end
    end

    attr_reader :extensions
    attr_accessor :vertex_wrapper, :edge_wrapper

    def initialize(extensions = [])
      @extensions = extensions
    end

    def wrapper(graph, element)
      if graph
        if element.is_a? Vertex
          self.vertex_wrapper ||= graph.base_vertex_wrapper.wrapper_for extensions
        elsif element.is_a? Edge
          self.edge_wrapper ||= graph.base_edge_wrapper.wrapper_for extensions
        end
      else
        if element.is_a? Vertex
          self.vertex_wrapper ||= Pacer::Wrappers::VertexWrapper.wrapper_for extensions
        elsif element.is_a? Edge
          self.edge_wrapper ||= Pacer::Wrappers::EdgeWrapper.wrapper_for extensions
        end
      end
    end

    def new(graph, element)
      w = wrapper(graph, element)
      if w
        w.new graph, element
      else
        element
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.22-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.20-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.19-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.18-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.17-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.16-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.15-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.14-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.13-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.12-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.10-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.10.pre-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.8-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.6-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.4.pre-java lib/pacer/wrappers/wrapper_selector.rb
pacer-2.0.0.pre-java lib/pacer/wrappers/wrapper_selector.rb
pacer-1.6.0-java lib/pacer/wrappers/wrapper_selector.rb
pacer-1.5.4-java lib/pacer/wrappers/wrapper_selector.rb
pacer-1.5.3-java lib/pacer/wrappers/wrapper_selector.rb