Sha256: b05d68b192274eaae041feb1ab40bed761921b0d83f6f55bb4f845e7d32c1ea8

Contents?: true

Size: 580 Bytes

Versions: 9

Compression:

Stored size: 580 Bytes

Contents

module Trestle
  class Hook
    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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/hook/set.rb
trestle-0.10.0 lib/trestle/hook/set.rb
trestle-0.10.0.pre2 lib/trestle/hook/set.rb
trestle-0.10.0.pre lib/trestle/hook/set.rb
trestle-0.9.8 lib/trestle/hook/set.rb
trestle-0.9.7 lib/trestle/hook/set.rb
trestle-0.9.6 lib/trestle/hook/set.rb
trestle-0.9.5 lib/trestle/hook/set.rb
trestle-0.9.4 lib/trestle/hook/set.rb