Sha256: 1675f1b809862b3bc3c64d114240343d82dc3bd21ec30e8285761420e7f987cc

Contents?: true

Size: 1.03 KB

Versions: 19

Compression:

Stored size: 1.03 KB

Contents

module Neo4j::ActiveNode
  module Property
    extend ActiveSupport::Concern
    include Neo4j::Shared::Property

    def initialize(attributes = {}, options = {})
      super(attributes, options)
      @attributes ||= self.class.attributes_nil_hash.dup
      send_props(@relationship_props) if _persisted_obj && !@relationship_props.nil?
    end

    module ClassMethods
      # Extracts keys from attributes hash which are associations of the model
      # TODO: Validate separately that relationships are getting the right values?  Perhaps also store the values and persist relationships on save?
      def extract_association_attributes!(attributes)
        return unless contains_association?(attributes)
        attributes.each_with_object({}) do |(key, _), result|
          result[key] = attributes.delete(key) if self.association?(key)
        end
      end

      private

      def contains_association?(attributes)
        attributes.each_key { |key| return true if associations_keys.include?(key) }
        false
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
neo4j-5.0.15 lib/neo4j/active_node/property.rb
neo4j-5.0.14 lib/neo4j/active_node/property.rb
neo4j-5.0.13 lib/neo4j/active_node/property.rb
neo4j-5.0.12 lib/neo4j/active_node/property.rb
neo4j-5.0.11 lib/neo4j/active_node/property.rb
neo4j-5.0.10 lib/neo4j/active_node/property.rb
neo4j-5.0.9 lib/neo4j/active_node/property.rb
neo4j-5.0.8 lib/neo4j/active_node/property.rb
neo4j-5.0.7 lib/neo4j/active_node/property.rb
neo4j-5.0.6 lib/neo4j/active_node/property.rb
neo4j-5.0.5 lib/neo4j/active_node/property.rb
neo4j-5.0.4 lib/neo4j/active_node/property.rb
neo4j-5.0.3 lib/neo4j/active_node/property.rb
neo4j-5.0.2 lib/neo4j/active_node/property.rb
neo4j-5.0.1 lib/neo4j/active_node/property.rb
neo4j-5.0.0 lib/neo4j/active_node/property.rb
neo4j-5.0.0.rc.3 lib/neo4j/active_node/property.rb
neo4j-5.0.0.rc.2 lib/neo4j/active_node/property.rb
neo4j-5.0.0.rc.1 lib/neo4j/active_node/property.rb