Sha256: d554d7c0e67ee73bbe036f6ab59bcd7114436d062f1d782766770589a9cdfcfa
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 Bytes
Contents
module InstDataShipper module Hooks extend ActiveSupport::Concern class_methods do def define_hook(name) @hooks ||= {} @hooks[name] ||= [] end def hook(name, prepend: false, &block) hooks = @hooks[name] prepend ? hooks.unshift(block) : hooks << block end end def run_hook(name, *args, **kwargs) hooks = @hooks[name] hooks.each do |blk| instance_exec(*args, **kwargs, &blk) end end def run_hook_safe(name, *args, **kwargs) hooks = @hooks[name] hooks.each do |blk| instance_exec(*args, **kwargs, &blk) rescue StandardError end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inst_data_shipper-0.1.0.beta1 | lib/inst_data_shipper/concerns/hooks.rb |