Module: PumaAfterReply

Defined in:
lib/puma_after_reply.rb,
lib/puma_after_reply/version.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: Config, RepliesRunner Classes: Middleware, ReplyCollector

Constant Summary collapse

VERSION =

Returns:

  • (String)

Since:

  • 0.1.0

'0.1.0'

Class Method Summary collapse

Class Method Details

.add_reply(threaded: false, &reply) ⇒ void

This method returns an undefined value.

Add reply to the reply collector, without any conditions.

Parameters:

  • reply (Block)
  • threaded (Hash) (defaults to: false)

    a customizable set of options

Options Hash (threaded:):

  • (Boolean)

Since:

  • 0.1.0



23
24
25
# File 'lib/puma_after_reply.rb', line 23

def add_reply(threaded: false, &reply)
  ReplyCollector.current.add_reply(reply, threaded:)
end

.callvoid Also known as: run

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.

DEBUGGING METHOD

Should not be invoked directly in the business code! Run all currently added replies directly. Imporant: remember that reply collector will be flushed.

Since:

  • 0.1.0



113
114
115
# File 'lib/puma_after_reply.rb', line 113

def call
  RepliesRunner.call
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.

DEBUGGING METHOD

Since:

  • 0.1.0



124
125
126
# File 'lib/puma_after_reply.rb', line 124

def clear
  ReplyCollector.current.clear
end

.cond_reply(factor, threaded: false, &reply) ⇒ void, Any

Add reply to the reply collector condotionally using the boolean factor. If a factor is a callable object - it will be called and the result will be threatet as a factor. If a factor is a true value => your reply block will be added to the replies collector. If a factor is a false value => your reply block will be yielded immediatly.

Parameters:

  • factor (Boolean, #call)
  • reply (Block)
  • threaded (Hash) (defaults to: false)

    a customizable set of options

Options Hash (threaded:):

  • (Boolean)

Returns:

  • (void, Any)

Since:

  • 0.1.0



40
41
42
43
# File 'lib/puma_after_reply.rb', line 40

def cond_reply(factor, threaded: false, &reply)
  is_addable = factor.respond_to?(:call) ? factor.call : factor
  is_addable ? add_reply(threaded:, &reply) : yield
end

.configPumaAfterReply::Config

Returns:

Since:

  • 0.1.0



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

def config
  PumaAfterReply::Config
end

.configure(&block) ⇒ void

This method returns an undefined value.

Parameters:

  • block (Block)

Since:

  • 0.1.0



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

def configure(&block)
  Config.configure(&block)
end

.countInteger Also known as: size

Return the count of currently added replies.

Returns:

  • (Integer)

Since:

  • 0.1.0



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

def count
  ReplyCollector.current.size
end

.inline_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.

DEBUGGING METHOD

Returns:

  • (Array<#call|Proc>)

Since:

  • 0.1.0



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

def inline_replies
  ReplyCollector.current.inline_replies
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.

DEBUGGING METHOD

Returns:

  • (Array<#call|Proc>)

Since:

  • 0.1.0



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

def replies
  ReplyCollector.current.replies
end

.threaded_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.

DEBUGGING METHOD

Returns:

  • (Array<#call|Proc>)

Since:

  • 0.1.0



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

def threaded_replies
  ReplyCollector.current.threaded_replies
end