Class: DataMapper::SubjectSet::NameCache Private

Inherits:
Object
  • Object
show all
Includes:
OrderedSet::Cache::API
Defined in:
lib/dm-core/support/subject_set.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An OrderedSet::Cache::API implementation that establishes set semantics based on the name of its entries. The cache uses the entries’ names as cache key and refuses to add entries that don’t respond_to?(:name).

Instance Method Summary collapse

Methods included from OrderedSet::Cache::API

#[], #[]=, #clear, #delete, #include?, #initialize

Instance Method Details

#key_for(entry) ⇒ #to_s?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Given an entry, return the key to be used in the cache

Parameters:

  • entry (#name)

    the entry to get the key for

Returns:

  • (#to_s, nil)

    the entry’s name or nil if the entry isn’t #valid?



76
77
78
# File 'lib/dm-core/support/subject_set.rb', line 76

def key_for(entry)
  valid?(entry) ? entry.name : nil
end

#valid?(entry) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Tests if the given entry qualifies to be added to the cache

Parameters:

  • entry (#name)

    the entry to be checked

Returns:

  • (Boolean)

    true if the entry respond_to?(:name)



63
64
65
# File 'lib/dm-core/support/subject_set.rb', line 63

def valid?(entry)
  entry.respond_to?(:name)
end