Class: Checkpoint::Resource::AnyEntityOfType
- Inherits:
-
Object
- Object
- Checkpoint::Resource::AnyEntityOfType
- 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
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Always returns true; this wildcard is “equal” to any object.
-
#initialize(type) ⇒ AnyEntityOfType
constructor
Create a wildcard entity that will compare as equal to.
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
#type ⇒ Object (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
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 |