Class: Trestle::Hook::Set
- Inherits:
-
Object
- Object
- Trestle::Hook::Set
- Defined in:
- lib/trestle/hook.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.
30 31 32 |
# File 'lib/trestle/hook.rb', line 30 def initialize @hooks = {} end |
Instance Attribute Details
#hooks ⇒ Object (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
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, ={}, &block) hooks[name.to_s] ||= [] hooks[name.to_s] << Hook.new(name.to_s, , &block) end |
#empty? ⇒ 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 |