Class: Delta::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/delta/identifier.rb

Direct Known Subclasses

Null

Defined Under Namespace

Classes: Null

Instance Method Summary collapse

Constructor Details

#initialize(keys) ⇒ Identifier

Returns a new instance of Identifier.



3
4
5
# File 'lib/delta/identifier.rb', line 3

def initialize(keys)
  self.keys = keys
end

Instance Method Details

#identities(collection) ⇒ Object



11
12
13
# File 'lib/delta/identifier.rb', line 11

def identities(collection)
  cache(collection) { Hash[keys.map { |k| [k, collection.pluck(k).uniq] }] }
end

#identity(object) ⇒ Object



7
8
9
# File 'lib/delta/identifier.rb', line 7

def identity(object)
  cache(object) { Hash[keys.map { |k| [k, object.public_send(k)] }] }
end