Class: Hookd::HookActivity
- Inherits:
-
Object
- Object
- Hookd::HookActivity
- Defined in:
- lib/hookd/hook_activity.rb
Overview
Summarises a long-lived hook that currently has pending interactions, returned by Client#activity.
Instance Attribute Summary collapse
-
#hook ⇒ Object
readonly
Returns the value of attribute hook.
-
#last_interaction_at ⇒ Object
readonly
Returns the value of attribute last_interaction_at.
-
#pending_count ⇒ Object
readonly
Returns the value of attribute pending_count.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Create a HookActivity from an API response hash.
Instance Method Summary collapse
-
#initialize(hook:, pending_count:, last_interaction_at:) ⇒ HookActivity
constructor
A new instance of HookActivity.
- #to_s ⇒ Object
Constructor Details
#initialize(hook:, pending_count:, last_interaction_at:) ⇒ HookActivity
Returns a new instance of HookActivity.
9 10 11 12 13 |
# File 'lib/hookd/hook_activity.rb', line 9 def initialize(hook:, pending_count:, last_interaction_at:) @hook = hook @pending_count = pending_count @last_interaction_at = last_interaction_at end |
Instance Attribute Details
#hook ⇒ Object (readonly)
Returns the value of attribute hook.
7 8 9 |
# File 'lib/hookd/hook_activity.rb', line 7 def hook @hook end |
#last_interaction_at ⇒ Object (readonly)
Returns the value of attribute last_interaction_at.
7 8 9 |
# File 'lib/hookd/hook_activity.rb', line 7 def last_interaction_at @last_interaction_at end |
#pending_count ⇒ Object (readonly)
Returns the value of attribute pending_count.
7 8 9 |
# File 'lib/hookd/hook_activity.rb', line 7 def pending_count @pending_count end |
Class Method Details
.from_hash(hash) ⇒ Object
Create a HookActivity from an API response hash
16 17 18 19 20 21 22 23 24 |
# File 'lib/hookd/hook_activity.rb', line 16 def self.from_hash(hash) raise ArgumentError, "Invalid hash: expected Hash, got #{hash.class}" unless hash.is_a?(Hash) new( hook: Hook.from_hash(hash['hook']), pending_count: hash['pending_count'], last_interaction_at: hash['last_interaction_at'] ) end |
Instance Method Details
#to_s ⇒ Object
26 27 28 |
# File 'lib/hookd/hook_activity.rb', line 26 def to_s "#<Hookd::HookActivity hook=#{hook.id} pending=#{pending_count}>" end |