Sha256: 1d117412c5475364924775ce731d3c6d3bf72d0480aa3b2d41dbc5e0b7e91f7c

Contents?: true

Size: 878 Bytes

Versions: 41

Compression:

Stored size: 878 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)
          most_concrete_class.constantize.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

41 entries across 41 versions & 1 rubygems

Version Path
neo4j-8.0.5 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.4 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.3 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.2 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.1 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.rc.4 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.rc.3 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.rc.2 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.rc.1 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.12 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.11 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.10 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.9 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.8 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.7 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.6 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.5 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.4 lib/neo4j/active_rel/rel_wrapper.rb
neo4j-8.0.0.alpha.2 lib/neo4j/active_rel/rel_wrapper.rb