Class: Dough::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/dough/id.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hashObject (readonly)

Returns the value of attribute hash.



7
8
9
# File 'lib/dough/id.rb', line 7

def hash
  @hash
end

#ingredientObject (readonly)

Returns the value of attribute ingredient.



6
7
8
# File 'lib/dough/id.rb', line 6

def ingredient
  @ingredient
end

#shaObject (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: ==

Returns:

  • (Boolean)


25
26
27
# File 'lib/dough/id.rb', line 25

def eql?(other)
	other.is_a?(ID) && @hash == other.hash && @sha == other.sha
end

#updateObject

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