Class: Checkpoint::Resource::AllOfType
- Inherits:
-
Checkpoint::Resource
- Object
- Checkpoint::Resource
- Checkpoint::Resource::AllOfType
- Defined in:
- lib/checkpoint/resource/all_of_type.rb
Overview
Specialized Resource type to represent all entities of a particular type.
Constant Summary
Constants inherited from Checkpoint::Resource
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Checkpoint::Resource
Class Method Summary collapse
-
.from(entity) ⇒ Object
Create a type-specific wildcard Resource from a given entity.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Compares with another Resource.
-
#id ⇒ Object
This is always the special ALL resource ID.
-
#initialize(type) ⇒ AllOfType
constructor
Create a wildcard Resource for a given type.
Methods inherited from Checkpoint::Resource
Constructor Details
#initialize(type) ⇒ AllOfType
Create a wildcard Resource for a given type
9 10 11 |
# File 'lib/checkpoint/resource/all_of_type.rb', line 9 def initialize(type) @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/checkpoint/resource/all_of_type.rb', line 7 def type @type end |
Class Method Details
.from(entity) ⇒ Object
Create a type-specific wildcard Resource from a given entity
When the entity implements to #to_resource, we convert it first and take the type from the result. Otherwise, when it implements #resource_type, we use that result. Otherwise, we take the class name of the entity. Regardless of the source, the type is forced to a string.
19 20 21 |
# File 'lib/checkpoint/resource/all_of_type.rb', line 19 def self.from(entity) new(type_of(entity)) end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Compares with another Resource
31 32 33 |
# File 'lib/checkpoint/resource/all_of_type.rb', line 31 def eql?(other) other.is_a?(Resource) && type == other.type end |