Class: Agents::Agent
- Inherits:
-
Object
- Object
- Agents::Agent
- Defined in:
- lib/agents/agent.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
Instance Method Summary collapse
-
#handle(request:) ⇒ Response
Response.
-
#initialize(actions: []) ⇒ Agent
constructor
A new instance of Agent.
- #register(action:) ⇒ Object
- #unregister(action:) ⇒ Object
Constructor Details
#initialize(actions: []) ⇒ Agent
Returns a new instance of Agent.
5 6 7 |
# File 'lib/agents/agent.rb', line 5 def initialize(actions: []) @actions = actions end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
3 4 5 |
# File 'lib/agents/agent.rb', line 3 def actions @actions end |
Instance Method Details
#handle(request:) ⇒ Response
Returns response.
11 12 13 |
# File 'lib/agents/agent.rb', line 11 def handle(request:) Response.new("Sorry, this agent doesn't know how to handle requests.") end |
#register(action:) ⇒ Object
15 16 17 |
# File 'lib/agents/agent.rb', line 15 def register(action:) @actions << action end |
#unregister(action:) ⇒ Object
19 20 21 |
# File 'lib/agents/agent.rb', line 19 def unregister(action:) @actions.delete(action) end |