Sha256: 884b71ea73839366b610eb063a354fa5ea353ad6c5fdd84b3554897bc6cbd783

Contents?: true

Size: 983 Bytes

Versions: 26

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

wrapping_proc = proc do |relationship|
  ActiveGraph::RelWrapping.wrapper(relationship)
end
Neo4j::Driver::Types::Relationship.wrapper_callback(wrapping_proc)

module ActiveGraph
  module RelWrapping
    class << self
      def wrapper(rel)
        rel.properties.symbolize_keys!
        begin
          most_concrete_class = class_from_type(rel.type).constantize
          return rel unless most_concrete_class < ActiveGraph::Relationship
          most_concrete_class.new
        rescue NameError => e
          raise e unless e.message =~ /(uninitialized|wrong) constant/

          return rel
        end.tap do |wrapped_rel|
          wrapped_rel.init_on_load(rel, rel.start_node_id, rel.end_node_id, rel.type)
        end
      end

      def class_from_type(type)
        ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] = type.to_s.downcase.camelize
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
activegraph-11.4.0 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.3.1 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.3.0 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.2.0 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0.beta.1 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0.alpha.4 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0.alpha.3 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0.alpha.2 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.1.0.alpha.1 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.2.0.beta.1 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.2-java lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.1.1 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.1-java lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.0-java lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.1.0 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.0.beta.4-java lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.2 lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.0.beta.3-java lib/active_graph/relationship/rel_wrapper.rb
activegraph-11.0.0.beta.2-java lib/active_graph/relationship/rel_wrapper.rb