Module: Verifly::DependentCallbacks::Storage

Included in:
Verifly::DependentCallbacks
Defined in:
lib/verifly/dependent_callbacks/storage.rb

Overview

Subset of DependentCallbacks dsl methods, which could be used in callbacks storage

Instance Method Summary collapse

Instance Method Details

#callback_groups(*groups) ⇒ Object

Declares callback groups with given names. This creates before_ after_ and around_ signleton methods for each group given

Parameters:

  • groups ([Symbol])

See Also:



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/verifly/dependent_callbacks/storage.rb', line 11

def callback_groups(*groups)
  groups.each do |group|
    dependent_callbacks_service.groups[group] # Creates an empty group

    %i[before after around].each do |position|
      define_singleton_method("#{position}_#{group}") do |*args, &block|
        dependent_callbacks_service.add_callback(position, group, *args, &block)
      end
    end
  end
end

#dependent_callbacks_serviceService

Returns associated with current Class / Module.

Returns:

  • (Service)

    associated with current Class / Module



31
32
33
# File 'lib/verifly/dependent_callbacks/storage.rb', line 31

def dependent_callbacks_service
  @dependent_callbacks_service ||= Service.new
end

#merge_callbacks_from(storage) ⇒ Object

Merges all callbacks from given storage

Parameters:

  • storage (Module { extend Storage })


25
26
27
28
# File 'lib/verifly/dependent_callbacks/storage.rb', line 25

def merge_callbacks_from(storage)
  include(storage)
  dependent_callbacks_service.merge!(storage.dependent_callbacks_service)
end