class Prong::Hooks::Chain
Public Class Methods
new(base, name)
click to toggle source
# File lib/prong/hooks/chain.rb, line 4 def initialize(base, name) @base = base @name = name end
Public Instance Methods
compile(block, type)
click to toggle source
# File lib/prong/hooks/chain.rb, line 13 def compile(block, type) callbacks = instance_variable_get("@#{type}") callbacks[0][callbacks[1]] = [block,[]] return callbacks[0] end
prepare()
click to toggle source
# File lib/prong/hooks/chain.rb, line 9 def prepare all; before; after; around; return self end
Private Instance Methods
after()
click to toggle source
# File lib/prong/hooks/chain.rb, line 30 def after @after = [(['_***_'] + get_after)] @after << @after[0].index('_***_') end
all()
click to toggle source
# File lib/prong/hooks/chain.rb, line 20 def all @all = [([] + get_before + get_around + ['_***_'] + get_around + get_after)] @all << @all[0].index('_***_') end
around()
click to toggle source
# File lib/prong/hooks/chain.rb, line 35 def around @around = [(get_around + ['_***_'] + get_around)] @around << @around[0].index('_***_') end
before()
click to toggle source
# File lib/prong/hooks/chain.rb, line 25 def before @before = [([] + get_before + ['_***_'])] @before << @before[0].index('_***_') end
deep_dup(array)
click to toggle source
# File lib/prong/hooks/chain.rb, line 52 def deep_dup(array) array.map do |it| if it.class == Array # recursive method call instead of while loop next deep_dup(it.dup) else next it end end end
get_after()
click to toggle source
# File lib/prong/hooks/chain.rb, line 48 def get_after @get_after ||= deep_dup(@base.send("_after_#{@name}")) end
get_around()
click to toggle source
# File lib/prong/hooks/chain.rb, line 44 def get_around @get_around ||= deep_dup(@base.send("_around_#{@name}")) end
get_before()
click to toggle source
# File lib/prong/hooks/chain.rb, line 40 def get_before @get_before ||= deep_dup(@base.send("_before_#{@name}")) end