Class: Agents::StateCodeAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::StateCodeAgent
- Includes:
- Carmen
- Defined in:
- lib/huginn_state_code_agent/state_code_agent.rb
Instance Method Summary collapse
- #check ⇒ Object
- #default_options ⇒ Object
- #receive(incoming_events) ⇒ Object
- #validate_options ⇒ Object
- #working? ⇒ Boolean
Instance Method Details
#check ⇒ Object
98 99 100 |
# File 'lib/huginn_state_code_agent/state_code_agent.rb', line 98 def check handle interpolated(event.payload)['payload'].presence || {} end |
#default_options ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/huginn_state_code_agent/state_code_agent.rb', line 71 def { 'country' => '', 'region' => '', 'output_mode' => 'clean', } end |
#receive(incoming_events) ⇒ Object
102 103 104 105 106 |
# File 'lib/huginn_state_code_agent/state_code_agent.rb', line 102 def receive(incoming_events) incoming_events.each do |event| handle(event) end end |
#validate_options ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/huginn_state_code_agent/state_code_agent.rb', line 79 def unless ['country'].present? errors.add(:base, 'country is a required field') end unless ['region'].present? errors.add(:base, 'region is a required field') end if ['output_mode'].present? && !['output_mode'].to_s.include?('{') && !%[clean merge].include?(['output_mode'].to_s) errors.add(:base, "if provided, output_mode must be 'clean' or 'merge'") end end |
#working? ⇒ Boolean
94 95 96 |
# File 'lib/huginn_state_code_agent/state_code_agent.rb', line 94 def working? received_event_without_error? end |