lib/trestle/hook.rb in trestle-0.9.3 vs lib/trestle/hook.rb in trestle-0.9.4
- old
+ new
@@ -1,7 +1,10 @@
module Trestle
class Hook
+ require_relative "hook/helpers"
+ require_relative "hook/set"
+
attr_reader :name, :options, :block
def initialize(name, options={}, &block)
@name, @options, @block = name, options, block
end
@@ -20,37 +23,8 @@
end
end
def evaluate(context, *args)
context.instance_exec(*args, &block)
- end
-
- class Set
- attr_reader :hooks
-
- def initialize
- @hooks = {}
- end
-
- def append(name, options={}, &block)
- hooks[name.to_s] ||= []
- hooks[name.to_s] << Hook.new(name.to_s, options, &block)
- end
-
- def any?(name)
- hooks.key?(name.to_s) && hooks[name.to_s].any?
- end
-
- def for(name)
- hooks.fetch(name.to_s) { [] }
- end
-
- def empty?
- hooks.empty?
- end
-
- def ==(other)
- other.is_a?(self.class) && hooks == other.hooks
- end
end
end
end