Class: Dough::ID
- Inherits:
-
Object
- Object
- Dough::ID
- Defined in:
- lib/dough/id.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#ingredient ⇒ Object
readonly
Returns the value of attribute ingredient.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #===(other) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(ingredient) ⇒ ID
constructor
A new instance of ID.
-
#update ⇒ Object
Public: Refresh the id.
Constructor Details
#initialize(ingredient) ⇒ ID
Returns a new instance of ID.
10 11 12 13 |
# File 'lib/dough/id.rb', line 10 def initialize(ingredient) @ingredient = ingredient # update end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
7 8 9 |
# File 'lib/dough/id.rb', line 7 def hash @hash end |
#ingredient ⇒ Object (readonly)
Returns the value of attribute ingredient.
6 7 8 |
# File 'lib/dough/id.rb', line 6 def ingredient @ingredient end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
8 9 10 |
# File 'lib/dough/id.rb', line 8 def sha @sha end |
Instance Method Details
#===(other) ⇒ Object
30 31 32 |
# File 'lib/dough/id.rb', line 30 def ===(other) self == other || super end |
#eql?(other) ⇒ Boolean Also known as: ==
25 26 27 |
# File 'lib/dough/id.rb', line 25 def eql?(other) other.is_a?(ID) && @hash == other.hash && @sha == other.sha end |
#update ⇒ Object
Public: Refresh the id
Returns self
18 19 20 21 22 23 |
# File 'lib/dough/id.rb', line 18 def update @sha = Digest::SHA1.hexdigest ingredient.marshalled @hash = ingredient.marshalled.hash self end |