module Verifly::DependentCallbacks::Storage

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

Public Instance Methods

callback_groups(*groups) click to toggle source

Declares callback groups with given names. This creates before_ after_ and around_ signleton methods for each group given @see Service#add_callback @param groups [[Symbol]]

# 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_service() click to toggle source

@return [Service] associated with current Class / Module

# File lib/verifly/dependent_callbacks/storage.rb, line 31
def dependent_callbacks_service
  @dependent_callbacks_service ||= Service.new
end
merge_callbacks_from(storage) click to toggle source

Merges all callbacks from given storage @param storage [Module { extend Storage }]

# 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