Class: InstagramConnect::Ingest::Summary
- Inherits:
-
Object
- Object
- InstagramConnect::Ingest::Summary
- Includes:
- Enumerable
- Defined in:
- lib/instagram_connect/ingest/summary.rb
Overview
What one webhook delivery produced. Behaves as a Hash so the return value of Ingest.call stays compatible with hosts written against 0.2.x, which read summary and friends.
Constant Summary collapse
- COUNTERS =
{ "messages" => :messages, "message_echoes" => :messages, "messaging_postbacks" => :postbacks, "comments" => :comments, "live_comments" => :comments }.freeze
Instance Attribute Summary collapse
-
#callback_errors ⇒ Object
Returns the value of attribute callback_errors.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#duplicates ⇒ Object
Returns the value of attribute duplicates.
-
#failed ⇒ Object
Returns the value of attribute failed.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#postbacks ⇒ Object
Returns the value of attribute postbacks.
-
#unhandled ⇒ Object
Returns the value of attribute unhandled.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #count(field) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Summary
constructor
A new instance of Summary.
-
#skipped ⇒ Object
0.2.x reported one
skippednumber covering both "we have seen this already" and "we do not parse this". - #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize ⇒ Summary
Returns a new instance of Summary.
18 19 20 21 22 23 24 25 26 |
# File 'lib/instagram_connect/ingest/summary.rb', line 18 def initialize @messages = 0 @comments = 0 @postbacks = 0 @duplicates = 0 @unhandled = 0 @failed = 0 @callback_errors = 0 end |
Instance Attribute Details
#callback_errors ⇒ Object
Returns the value of attribute callback_errors.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def callback_errors @callback_errors end |
#comments ⇒ Object
Returns the value of attribute comments.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def comments @comments end |
#duplicates ⇒ Object
Returns the value of attribute duplicates.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def duplicates @duplicates end |
#failed ⇒ Object
Returns the value of attribute failed.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def failed @failed end |
#messages ⇒ Object
Returns the value of attribute messages.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def @messages end |
#postbacks ⇒ Object
Returns the value of attribute postbacks.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def postbacks @postbacks end |
#unhandled ⇒ Object
Returns the value of attribute unhandled.
15 16 17 |
# File 'lib/instagram_connect/ingest/summary.rb', line 15 def unhandled @unhandled end |
Instance Method Details
#==(other) ⇒ Object
65 66 67 |
# File 'lib/instagram_connect/ingest/summary.rb', line 65 def ==(other) other.respond_to?(:to_h) ? to_h == other.to_h : super end |
#[](key) ⇒ Object
61 62 63 |
# File 'lib/instagram_connect/ingest/summary.rb', line 61 def [](key) to_h[key.to_sym] end |
#count(field) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/instagram_connect/ingest/summary.rb', line 28 def count(field) counter = COUNTERS[field] return if counter.nil? public_send(:"#{counter}=", public_send(counter) + 1) end |
#each(&block) ⇒ Object
69 70 71 |
# File 'lib/instagram_connect/ingest/summary.rb', line 69 def each(&block) to_h.each(&block) end |
#skipped ⇒ Object
0.2.x reported one skipped number covering both "we have seen this
already" and "we do not parse this". They are different problems now —
duplicates are healthy, unhandled events are a backlog to replay — but
the combined figure is kept so existing hosts keep working.
39 40 41 |
# File 'lib/instagram_connect/ingest/summary.rb', line 39 def skipped duplicates + unhandled end |
#to_h ⇒ Object Also known as: to_hash
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/instagram_connect/ingest/summary.rb', line 43 def to_h { messages: , comments: comments, postbacks: postbacks, skipped: skipped, duplicates: duplicates, unhandled: unhandled, failed: failed, callback_errors: callback_errors } end |