Class: Trestle::Hook::Set
- Inherits:
-
Object
- Object
- Trestle::Hook::Set
- Defined in:
- lib/trestle/hook/set.rb
Instance Attribute Summary collapse
-
#hooks ⇒ Object
readonly
Returns the value of attribute hooks.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #any?(name) ⇒ Boolean
- #append(name, options = {}, &block) ⇒ Object
- #empty? ⇒ Boolean
- #for(name) ⇒ Object
-
#initialize ⇒ Set
constructor
A new instance of Set.
Constructor Details
#initialize ⇒ Set
Returns a new instance of Set.
6 7 8 |
# File 'lib/trestle/hook/set.rb', line 6 def initialize @hooks = {} end |
Instance Attribute Details
#hooks ⇒ Object (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
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, ={}, &block) hooks[name.to_s] ||= [] hooks[name.to_s] << Hook.new(name.to_s, , &block) end |
#empty? ⇒ 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 |