Class: Archipelago::Disco::ServiceDescription
- Inherits:
-
Object
- Object
- Archipelago::Disco::ServiceDescription
- Extended by:
- Forwardable
- Defined in:
- lib/archipelago/disco.rb
Overview
A Hash-like description of a service.
Constant Summary collapse
- IGNORABLE_ATTRIBUTES =
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#eql?(o) ⇒ Boolean
Returns whether our @attributes are equal to that of
o
. -
#initialize(hash = {}) ⇒ ServiceDescription
constructor
Initialize this service description with a hash that describes its attributes.
-
#matches?(match) ⇒ Boolean
Returns whether this ServiceDescription matches the given
match
.
Constructor Details
#initialize(hash = {}) ⇒ ServiceDescription
Initialize this service description with a hash that describes its attributes.
309 310 311 |
# File 'lib/archipelago/disco.rb', line 309 def initialize(hash = {}) @attributes = hash end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
303 304 305 |
# File 'lib/archipelago/disco.rb', line 303 def attributes @attributes end |
Instance Method Details
#eql?(o) ⇒ Boolean
Returns whether our @attributes are equal to that of o
.
315 316 317 |
# File 'lib/archipelago/disco.rb', line 315 def eql?(o) ServiceDescription === o && @attributes == o.attributes end |
#matches?(match) ⇒ Boolean
Returns whether this ServiceDescription matches the given match
.
321 322 323 324 325 326 327 328 |
# File 'lib/archipelago/disco.rb', line 321 def matches?(match) match.each do |key, value| unless IGNORABLE_ATTRIBUTES.include?(key) return false unless @attributes.include?(key) && (value.nil? || @attributes[key] == value) end end true end |