Module: HaveAPI::Hookable::InstanceMethods
- Defined in:
- lib/haveapi/hooks.rb
Instance Method Summary collapse
-
#call_class_hooks_as_for(klass, *args) ⇒ Object
Call only class hooks for different
klass
. -
#call_class_hooks_for(name, where = nil, args: [], initial: {}) ⇒ Object
Call only class hooks.
-
#call_hooks_as_for(klass, *args) ⇒ Object
Call hooks for different
klass
. -
#call_hooks_for(*args) ⇒ Object
Call all instance and class hooks.
-
#call_instance_hooks_as_for(klass, *args) ⇒ Object
Call only instance hooks for different
klass
. -
#call_instance_hooks_for(name, where = nil, args: [], initial: {}) ⇒ Object
Call only instance hooks.
-
#connect_hook(name, &block) ⇒ Object
Connect instance level hook
name
toblock
.
Instance Method Details
#call_class_hooks_as_for(klass, *args) ⇒ Object
Call only class hooks for different klass
.
244 245 246 |
# File 'lib/haveapi/hooks.rb', line 244 def call_class_hooks_as_for(klass, *args) Hooks.call_for(klass, *args) end |
#call_class_hooks_for(name, where = nil, args: [], initial: {}) ⇒ Object
Call only class hooks.
228 229 230 |
# File 'lib/haveapi/hooks.rb', line 228 def call_class_hooks_for(name, where = nil, args: [], initial: {}) Hooks.call_for(self.class, name, where, args: args, initial: initial) end |
#call_hooks_as_for(klass, *args) ⇒ Object
Call hooks for different klass
.
233 234 235 236 |
# File 'lib/haveapi/hooks.rb', line 233 def call_hooks_as_for(klass, *args) ret = call_instance_hooks_as_for(klass, *args) call_class_hooks_as_for(klass.class, *args, initial: ret) end |
#call_hooks_for(*args) ⇒ Object
Call all instance and class hooks.
211 212 213 214 215 216 217 218 219 220 |
# File 'lib/haveapi/hooks.rb', line 211 def call_hooks_for(*args) ret = call_instance_hooks_for(*args) if args.last.is_a?(::Hash) args.last.update(initial: ret) call_class_hooks_for(*args) else call_class_hooks_for(*args, initial: ret) end end |
#call_instance_hooks_as_for(klass, *args) ⇒ Object
Call only instance hooks for different klass
.
239 240 241 |
# File 'lib/haveapi/hooks.rb', line 239 def call_instance_hooks_as_for(klass, *args) Hooks.call_for(klass, *args) end |
#call_instance_hooks_for(name, where = nil, args: [], initial: {}) ⇒ Object
Call only instance hooks.
223 224 225 |
# File 'lib/haveapi/hooks.rb', line 223 def call_instance_hooks_for(name, where = nil, args: [], initial: {}) Hooks.call_for(self, name, where, args: args, initial: initial) end |
#connect_hook(name, &block) ⇒ Object
Connect instance level hook name
to block
.
249 250 251 |
# File 'lib/haveapi/hooks.rb', line 249 def connect_hook(name, &block) Hooks.connect_instance_hook(self, name, &block) end |