Module: Verifly::DependentCallbacks
- Extended by:
- HasLogger
- Includes:
- Storage
- Defined in:
- lib/verifly/dependent_callbacks.rb,
lib/verifly/dependent_callbacks/invoker.rb,
lib/verifly/dependent_callbacks/service.rb,
lib/verifly/dependent_callbacks/storage.rb,
lib/verifly/dependent_callbacks/callback.rb,
lib/verifly/dependent_callbacks/callback_group.rb
Overview
DependentCallbacks interface is similar to ActiveSupport::Callbacks, but it has few differences
1) ‘extend` it, not `include`
2) Use ‘.callback_groups` do tefine callbacks instead of define_callbacks
3) Better define callbacks in separate module, wich should extend DependentCallbacks::Storage
4) Use merge_callbacks_from(Module) instead of including it
5) There is no run_callbacks method.
You can either use self.class.dependent_callbacks.invoke(group, *context) {} or use .export_callbacks_to(:active_support) / .export_callbacks_to(:wrap_method)
Defined Under Namespace
Modules: Storage Classes: Callback, CallbackGroup, Service
Instance Attribute Summary
Attributes included from HasLogger
Instance Method Summary collapse
-
#export_callbacks_to(target, groups: nil) ⇒ Object
Exports callbacks to another callback system / something like that.
-
#inherited(child) ⇒ Object
Allows children to inherit callbacks from parent.
Methods included from Storage
#callback_groups, #dependent_callbacks_service, #merge_callbacks_from
Instance Method Details
#export_callbacks_to(target, groups: nil) ⇒ Object
Exports callbacks to another callback system / something like that
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/verifly/dependent_callbacks.rb', line 48 def export_callbacks_to(target, groups: nil) (groups || dependent_callbacks_service.group_names).each do |group| case target when :active_support then _export_callback_group_to_active_support(group) when :action_controller then _export_callback_group_to_action_controller(group) when :wrap_method then _export_callback_group_to_method_wapper(group) else raise "#{target.inspect} export target unavailable. " \ "available targets are :active_support, :action_controller, :wrap_method" end end end |