Sha256: fe6b7e1df5f25fb485d9cabc73e667ec9853b451a8f16a4c57ff9c81403c8ffb

Contents?: true

Size: 842 Bytes

Versions: 29

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'active_graph/core/result'
require 'active_support/core_ext/module/attribute_accessors'

module ActiveGraph
  module Core
    module Record
      attr_writer :wrap

      def values
        wrap(super)
      end

      def first
        wrap(super)
      end

      def [](key)
        wrap(super)
      end

      def to_h
        wrap(super)
      end

      private

      def wrap(value)
        return value unless wrap?

        case value
        when Neo4j::Driver::Types::Entity
          value.wrap
        when Neo4j::Driver::Types::Path
          value
        when Hash
          value.transform_values(&method(:wrap))
        when Enumerable
          value.map!(&method(:wrap))
        else
          value
        end
      end

      def wrap?
        @wrap
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

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