Module: ConvenientService::Common::Plugins::CanHaveCallbacks::Concern

Includes:
Support::Concern
Included in:
Entities::Type
Defined in:
lib/convenient_service/common/plugins/can_have_callbacks/concern.rb

Class Method Summary collapse

Class Method Details

.after(method, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::Callback

Parameters:

  • method (Symbol)
  • kwargs (Hash{Symbol => Object})
  • block (Proc)

Returns:



40
41
42
# File 'lib/convenient_service/common/plugins/can_have_callbacks/concern.rb', line 40

def after(method, **kwargs, &block)
  callback(:after, method, **kwargs, &block)
end

.around(method, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::Callback

Parameters:

  • method (Symbol)
  • kwargs (Hash{Symbol => Object})
  • block (Proc)

Returns:



52
53
54
# File 'lib/convenient_service/common/plugins/can_have_callbacks/concern.rb', line 52

def around(method, **kwargs, &block)
  callback(:around, method, **kwargs, &block)
end

.before(method, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::Callback

Parameters:

  • method (Symbol)
  • kwargs (Hash{Symbol => Object})
  • block (Proc)

Returns:



28
29
30
# File 'lib/convenient_service/common/plugins/can_have_callbacks/concern.rb', line 28

def before(method, **kwargs, &block)
  callback(:before, method, **kwargs, &block)
end

.callback(type, method, **kwargs, &block) ⇒ ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::Callback

Parameters:

  • type (Symbol)
  • method (Symbol)
  • kwargs (Hash{Symbol => Object})
  • block (Proc)

Returns:



65
66
67
# File 'lib/convenient_service/common/plugins/can_have_callbacks/concern.rb', line 65

def callback(type, method, **kwargs, &block)
  callbacks.create(types: [type, method], block: block, **kwargs)
end

.callbacksConvenientService::Common::Plugins::CanHaveCallbacks::Entities::CallbackCollection

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.



16
17
18
# File 'lib/convenient_service/common/plugins/can_have_callbacks/concern.rb', line 16

def callbacks
  internals_class.cache.fetch(:callbacks) { Entities::CallbackCollection.new }
end