Class: SmartCore::Operation::Result::Callback

Inherits:
Basic
  • Object
show all
Defined in:
lib/smart_core/operation/result/callback.rb

Overview

Since:

  • 0.1.0

Constant Summary collapse

EMPTY_INVOKATION_CONTEXT =

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

Returns:

  • (NilClass)

Since:

  • 0.1.0

nil

Instance Method Summary collapse

Methods inherited from Basic

#failure?, #fatal?, #initialize, #success?

Constructor Details

This class inherits a constructor from SmartCore::Operation::Result::Basic

Instance Method Details

#call(context = EMPTY_INVOKATION_CONTEXT) ⇒ Any

Parameters:

  • context (Any) (defaults to: EMPTY_INVOKATION_CONTEXT)

Returns:

  • (Any)

Since:

  • 0.1.0



24
25
26
# File 'lib/smart_core/operation/result/callback.rb', line 24

def call(context = EMPTY_INVOKATION_CONTEXT)
  context == EMPTY_INVOKATION_CONTEXT ? callback.call : context.instance_eval(&callback)
end

#callback? {|SmartCore::Operation::Result::Callback| ... } ⇒ Boolean

Yields:

Returns:

  • (Boolean)

Since:

  • 0.1.0



33
34
35
# File 'lib/smart_core/operation/result/callback.rb', line 33

def callback?
  true.tap { yield(self) if block_given? }
end