Module: Toy::Identity
- Extended by:
- ActiveSupport::Concern
- Included in:
- Store
- Defined in:
- lib/toy.rb,
lib/toy/identity.rb,
lib/toy/identity/uuid_key_factory.rb,
lib/toy/identity/abstract_key_factory.rb,
lib/toy/identity/native_uuid_key_factory.rb
Defined Under Namespace
Modules: ClassMethods
Classes: AbstractKeyFactory, NativeUUIDKeyFactory, UUIDKeyFactory
Instance Method Summary
collapse
Instance Method Details
#eql?(other) ⇒ Boolean
Also known as:
==
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/toy/identity.rb', line 59
def eql?(other)
return true if self.class.eql?(other.class) &&
id == other.id
return true if other.respond_to?(:target) &&
self.class.eql?(other.target.class) &&
id == other.target.id
super
end
|
#equal?(other) ⇒ Boolean
72
73
74
75
76
77
|
# File 'lib/toy/identity.rb', line 72
def equal?(other)
if other.respond_to?(:proxy_respond_to?) && other.respond_to?(:target)
other = other.target
end
super other
end
|
#initialize(*args) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/toy/identity.rb', line 46
def initialize(*args)
super
write_attribute :id, self.class.next_key(self) unless id?
@changed_attributes.delete('id') if @changed_attributes
end
|
#initialize_copy(*args) ⇒ Object
54
55
56
57
|
# File 'lib/toy/identity.rb', line 54
def initialize_copy(*args)
super
write_attribute :id, self.class.next_key(self)
end
|
#key_factory ⇒ Object
42
43
44
|
# File 'lib/toy/identity.rb', line 42
def key_factory
self.class.key_factory
end
|
79
80
81
|
# File 'lib/toy/identity.rb', line 79
def to_key
key_factory.to_key(self)
end
|