Class: PumaAfterReply::ReplyCollector Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_after_reply/reply_collector.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



32
33
34
35
# File 'lib/puma_after_reply/reply_collector.rb', line 32

def initialize
  @inline_replies = []
  @threaded_replies = []
end

Instance Attribute Details

#inline_repliesArray<#call|Proc> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<#call|Proc>)

Since:

  • 0.1.0



20
21
22
# File 'lib/puma_after_reply/reply_collector.rb', line 20

def inline_replies
  @inline_replies
end

#threaded_repliesARray<#call|Proc> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (ARray<#call|Proc>)

Since:

  • 0.1.0



26
27
28
# File 'lib/puma_after_reply/reply_collector.rb', line 26

def threaded_replies
  @threaded_replies
end

Class Method Details

.currentPumaAfterReply::ReplyCollector

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Since:

  • 0.1.0



11
12
13
# File 'lib/puma_after_reply/reply_collector.rb', line 11

def current
  Thread.current[:puma_after_reply_replies_collector] ||= new
end

Instance Method Details

#add_reply(reply, threaded:) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • reply (#call, Proc)
  • threaded (Hash)

    a customizable set of options

Options Hash (threaded:):

  • (Boolean)

Since:

  • 0.1.0



43
44
45
# File 'lib/puma_after_reply/reply_collector.rb', line 43

def add_reply(reply, threaded:)
  threaded ? threaded_replies << reply : inline_replies << reply
end

#clearvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Since:

  • 0.1.0



67
68
69
70
# File 'lib/puma_after_reply/reply_collector.rb', line 67

def clear
  inline_replies.clear
  threaded_replies.clear
end

#inline__each(&block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • block (Block)

Since:

  • 0.1.0



99
100
101
102
103
# File 'lib/puma_after_reply/reply_collector.rb', line 99

def inline__each(&block)
  # :nocov:
  inline_replies.each(&block)
  # :nocov:
end

#inline__each_and_flush(&block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • block (Block)

Since:

  • 0.1.0



110
111
112
113
114
# File 'lib/puma_after_reply/reply_collector.rb', line 110

def inline__each_and_flush(&block)
  inline_replies.each(&block)
ensure
  inline_replies.clear
end

#repliesArray<#call,Proc>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<#call,Proc>)

Since:

  • 0.1.0



51
52
53
# File 'lib/puma_after_reply/reply_collector.rb', line 51

def replies
  threaded_replies + inline_replies
end

#sizeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)

Since:

  • 0.1.0



59
60
61
# File 'lib/puma_after_reply/reply_collector.rb', line 59

def size
  inline_replies.size + threaded_replies.size
end

#threaded__each(&block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • block (Block)

Since:

  • 0.1.0



77
78
79
80
81
# File 'lib/puma_after_reply/reply_collector.rb', line 77

def threaded__each(&block)
  # :nocov:
  threaded_replies.each(&block)
  # :nocov:
end

#threaded__each_and_flush(&block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • block (Block)

Since:

  • 0.1.0



88
89
90
91
92
# File 'lib/puma_after_reply/reply_collector.rb', line 88

def threaded__each_and_flush(&block)
  threaded_replies.each(&block)
ensure
  threaded_replies.clear
end