Sha256: 2df0cea8e0131f29485b23729644aea7f1d4ddc96a79824043e75e810dac2167

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require 'active_model/attribute_set'

module Neo4j
  class AttributeSet < ActiveModel::AttributeSet
    def initialize(attr_hash, attr_list)
      hashmap = Neo4j::LazyAttributeHash.new(attr_hash, attr_list)
      super(hashmap)
    end

    def method_missing(name, *args, **kwargs, &block)
      if defined?(name)
        attributes.send(:materialize).send(name, *args, **kwargs, &block)
      else
        super
      end
    end

    def respond_to_missing?(method, *)
      attributes.send(:materialize).respond_to?(method) || super
    end

    def keys
      attributes.send(:materialize).keys
    end

    def ==(other)
      other.is_a?(Neo4j::AttributeSet) ? super : to_hash == other
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activegraph-10.0.0.pre.alpha.11 lib/neo4j/attribute_set.rb
activegraph-10.0.0.pre.alpha.10 lib/neo4j/attribute_set.rb