Sha256: a8cb0663255d4fb3cb3d92927c118f0ca4bf5af0eb481e0da690e89cd00b81b9

Contents?: true

Size: 1009 Bytes

Versions: 8

Compression:

Stored size: 1009 Bytes

Contents

require 'active_graph/core/relationship'

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.props.symbolize_keys!
        begin
          most_concrete_class = class_from_type(rel.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(rel_type)
        ActiveGraph::Relationship::Types::WRAPPED_CLASSES[rel_type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[rel_type] = rel_type.to_s.downcase.camelize
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activegraph-10.0.0.pre.beta.8 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.7 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.6 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.5 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.4 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.3 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.2 lib/active_graph/relationship/rel_wrapper.rb
activegraph-10.0.0.pre.beta.1 lib/active_graph/relationship/rel_wrapper.rb