Class: Archipelago::Disco::ServiceDescription

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/archipelago/disco.rb

Overview

A Hash-like description of a service.

Direct Known Subclasses

Query, Record

Constant Summary collapse

IGNORABLE_ATTRIBUTES =

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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