Class: Checkpoint::Agent::Token
- Inherits:
-
Object
- Object
- Checkpoint::Agent::Token
- Defined in:
- lib/checkpoint/agent/token.rb
Overview
An Agent::Token is an identifier object for an Agent. It includes a type and an identifier. A Grant can be created for a Token. Concrete actors are resolved into a number of agents, and those agents’ tokens will be checked for matching grants.
Instance Attribute Summary collapse
-
#id ⇒ Object
(also: #agent_id)
readonly
Returns the value of attribute id.
-
#type ⇒ Object
(also: #agent_type)
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Compare with another Agent for equality.
-
#hash ⇒ Integer
Hash code based on to_s.
-
#initialize(type, id) ⇒ Token
constructor
Create a new Agent Token representing an actor in an application.
-
#to_s ⇒ String
A token string suitable for granting or matching grants for this agent.
-
#token ⇒ Token
Self; for convenience of taking an Agent or token.
-
#uri ⇒ String
(also: #inspect)
A URI for this agent, including its type and id.
Constructor Details
#initialize(type, id) ⇒ Token
Create a new Agent Token representing an actor in an application.
22 23 24 25 |
# File 'lib/checkpoint/agent/token.rb', line 22 def initialize(type, id) @type = type.to_s @id = id.to_s end |
Instance Attribute Details
#id ⇒ Object (readonly) Also known as: agent_id
Returns the value of attribute id.
10 11 12 |
# File 'lib/checkpoint/agent/token.rb', line 10 def id @id end |
#type ⇒ Object (readonly) Also known as: agent_type
Returns the value of attribute type.
10 11 12 |
# File 'lib/checkpoint/agent/token.rb', line 10 def type @type end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Compare with another Agent for equality. Consider them to represent the same resource if ‘other` is an Agent, has the same type, and same id.
44 45 46 |
# File 'lib/checkpoint/agent/token.rb', line 44 def eql?(other) other.is_a?(Token) && type == other.type && id == other.id end |
#hash ⇒ Integer
Returns hash code based on to_s.
49 50 51 |
# File 'lib/checkpoint/agent/token.rb', line 49 def hash to_s.hash end |
#to_s ⇒ String
Returns a token string suitable for granting or matching grants for this agent.
38 39 40 |
# File 'lib/checkpoint/agent/token.rb', line 38 def to_s "#{type}:#{id}" end |
#token ⇒ Token
Returns self; for convenience of taking an Agent or token.
33 34 35 |
# File 'lib/checkpoint/agent/token.rb', line 33 def token self end |
#uri ⇒ String Also known as: inspect
Returns a URI for this agent, including its type and id.
28 29 30 |
# File 'lib/checkpoint/agent/token.rb', line 28 def uri "agent://#{type}/#{id}" end |