Class: Archipelago::Disco::ServiceDescription
- Inherits:
-
Object
- Object
- Archipelago::Disco::ServiceDescription
- 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
-
#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. -
#method_missing(meth, *args, &block) ⇒ Object
Forwards as much as possible to our Hash.
Constructor Details
#initialize(hash = {}) ⇒ ServiceDescription
Initialize this service description with a hash that describes its attributes.
205 206 207 |
# File 'lib/archipelago/disco.rb', line 205 def initialize(hash = {}) @attributes = hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
Forwards as much as possible to our Hash.
211 212 213 214 215 216 217 |
# File 'lib/archipelago/disco.rb', line 211 def method_missing(meth, *args, &block) if @attributes.respond_to?(meth) @attributes.send(meth, *args, &block) else super(*args) end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
200 201 202 |
# File 'lib/archipelago/disco.rb', line 200 def attributes @attributes end |
Instance Method Details
#matches?(match) ⇒ Boolean
Returns whether this ServiceDescription matches the given match.
221 222 223 224 225 226 227 228 |
# File 'lib/archipelago/disco.rb', line 221 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 |