Class: Checkpoint::Resource::AnyEntityOfType

Inherits:
Object
  • Object
show all
Defined in:
lib/checkpoint/resource/any_entity_of_type.rb

Overview

Special class to represent any entity of a type. This is used for type-wide grants or checks. It is basically so AllOfType can have an entity rather than a nil.

Wildcards or null objects typically have somewhat strange semantics, and this is no exception. It will compare as eql? and == to any object that has the same type attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ AnyEntityOfType

Create a wildcard entity that will compare as equal to



16
17
18
# File 'lib/checkpoint/resource/any_entity_of_type.rb', line 16

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



13
14
15
# File 'lib/checkpoint/resource/any_entity_of_type.rb', line 13

def type
  @type
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Always returns true; this wildcard is “equal” to any object. return [Boolean] true

Returns:

  • (Boolean)


22
23
24
# File 'lib/checkpoint/resource/any_entity_of_type.rb', line 22

def eql?(other)
  other.respond_to?(:type) && type == other.type
end