Class: Trestle::Hook::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/trestle/hook/set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSet

Returns a new instance of Set.



6
7
8
# File 'lib/trestle/hook/set.rb', line 6

def initialize
  @hooks = {}
end

Instance Attribute Details

#hooksObject (readonly)

Returns the value of attribute hooks.



4
5
6
# File 'lib/trestle/hook/set.rb', line 4

def hooks
  @hooks
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/trestle/hook/set.rb', line 27

def ==(other)
  other.is_a?(self.class) && hooks == other.hooks
end

#any?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/trestle/hook/set.rb', line 15

def any?(name)
  hooks.key?(name.to_s) && hooks[name.to_s].any?
end

#append(name, options = {}, &block) ⇒ Object



10
11
12
13
# File 'lib/trestle/hook/set.rb', line 10

def append(name, options={}, &block)
  hooks[name.to_s] ||= []
  hooks[name.to_s] << Hook.new(name.to_s, options, &block)
end

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/trestle/hook/set.rb', line 23

def empty?
  hooks.empty?
end

#for(name) ⇒ Object



19
20
21
# File 'lib/trestle/hook/set.rb', line 19

def for(name)
  hooks.fetch(name.to_s) { [] }
end