Class: Resilient::Key
- Inherits:
-
Object
- Object
- Resilient::Key
- Defined in:
- lib/resilient/key.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.wrap(string_or_instance) ⇒ Object
Internal: Takes a string name or instance of a Key and always returns a Key instance.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(name) ⇒ Key
Returns a new instance of Key.
17 18 19 20 |
# File 'lib/resilient/key.rb', line 17 def initialize(name) raise TypeError, "name must be a String" unless name.is_a?(String) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/resilient/key.rb', line 15 def name @name end |
Class Method Details
.wrap(string_or_instance) ⇒ Object
Internal: Takes a string name or instance of a Key and always returns a Key instance.
6 7 8 9 10 11 12 13 |
# File 'lib/resilient/key.rb', line 6 def self.wrap(string_or_instance) case string_or_instance when self, NilClass string_or_instance else new(string_or_instance) end end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
22 23 24 |
# File 'lib/resilient/key.rb', line 22 def ==(other) self.class == other.class && name == other.name end |
#hash ⇒ Object
27 28 29 |
# File 'lib/resilient/key.rb', line 27 def hash @name.hash end |