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
nametoblock.
Instance Method Details
#call_class_hooks_as_for(klass, *args) ⇒ Object
Call only class hooks for different klass.
175 176 177 |
# File 'lib/haveapi/hooks.rb', line 175 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.
159 160 161 |
# File 'lib/haveapi/hooks.rb', line 159 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.
164 165 166 167 |
# File 'lib/haveapi/hooks.rb', line 164 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.
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/haveapi/hooks.rb', line 142 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.
170 171 172 |
# File 'lib/haveapi/hooks.rb', line 170 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.
154 155 156 |
# File 'lib/haveapi/hooks.rb', line 154 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.
180 181 182 |
# File 'lib/haveapi/hooks.rb', line 180 def connect_hook(name, &block) Hooks.connect_instance_hook(self, name, &block) end |