Sha256: 3d46c54616305040449e6f96e67815de5966267ecae4c51b84e40b4cca2eaff0

Contents?: true

Size: 945 Bytes

Versions: 40

Compression:

Stored size: 945 Bytes

Contents

require 'neo4j/core/relationship'

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

module Neo4j
  module RelWrapping
    class << self
      def wrapper(rel)
        rel.props.symbolize_keys!
        begin
          most_concrete_class = class_from_type(rel.rel_type).constantize
          return rel unless most_concrete_class < Neo4j::ActiveRel
          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(rel_type)
        Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] || Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] = rel_type.to_s.camelize
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
neo4j-9.6.2 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.6.1 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.6.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.5.3 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.5.2 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.5.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.4.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.3.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.2.4 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.2.3 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.2.2 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.2.1 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.2.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.8 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.7 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.6 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.5 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.4 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.3 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-9.1.2 lib/neo4j/active_rel/rel_wrapper.rb