Class: Trestle::Hook::Set

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSet

Returns a new instance of Set.



30
31
32
# File 'lib/trestle/hook.rb', line 30

def initialize
  @hooks = {}
end

Instance Attribute Details

#hooksObject (readonly)

Returns the value of attribute hooks.



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

def hooks
  @hooks
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
# File 'lib/trestle/hook.rb', line 51

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

#any?(name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/trestle/hook.rb', line 39

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

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



34
35
36
37
# File 'lib/trestle/hook.rb', line 34

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)


47
48
49
# File 'lib/trestle/hook.rb', line 47

def empty?
  hooks.empty?
end

#for(name) ⇒ Object



43
44
45
# File 'lib/trestle/hook.rb', line 43

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