class Jekyll::Assets::Hook
Constants
- HOOK_ALIASES
- HOOK_POINTS
Public Class Methods
all()
click to toggle source
# File lib/jekyll/assets/hook.rb, line 35 def self.all @_all ||= {} end
point(base, point, when_ = :late)
click to toggle source
# File lib/jekyll/assets/hook.rb, line 56 def self.point(base, point, when_ = :late) point = all[base][point] ||= { :early => Set.new, :late => Set.new } point[when_] end
register(base, point, when_ = :late, &block)
click to toggle source
# File lib/jekyll/assets/hook.rb, line 67 def self.register(base, point, when_ = :late, &block) raise UnknownHookError, base: base unless HOOK_POINTS.key?(base) point = HOOK_ALIASES[base][point] if HOOK_ALIASES.fetch(base, {}).key?(point) raise UnknownHookError, point: point unless HOOK_POINTS[base].include?(point) all[base] ||= {} point(base, point, when_) .add(block) end
trigger(base, point_, *args, &block)
click to toggle source
Trigger a hook, giving an optional block where we pass you the, proc we got and then you can do as you please (such as instance eval) but if you do not give us one then we simply pass the args.
# File lib/jekyll/assets/hook.rb, line 45 def self.trigger(base, point_, *args, &block) raise ArgumentError, "Do not give args with a block" if !args.empty? && block_given? if all.key?(base) && all[base].key?(point_) Set.new.merge(point(base, point_, :early)).merge(point(base, point_)).map do |v| block_given?? block.call(v) : v.call(*args) end end end