Module: HaveAPI::Hookable::InstanceMethods

Defined in:
lib/haveapi/hooks.rb

Instance Method Summary collapse

Instance Method Details

#call_class_hooks_as_for(klass) ⇒ Object

Call only class hooks for different ‘klass`.



246
247
248
# File 'lib/haveapi/hooks.rb', line 246

def call_class_hooks_as_for(klass, *, **)
  Hooks.call_for(klass, *, **)
end

#call_class_hooks_for(name, where = nil, args: [], kwargs: {}, 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: [], kwargs: {}, initial: {})
  Hooks.call_for(self.class, name, where, args:, kwargs:, initial:)
end

#call_hooks_as_for(klass, **kwargs) ⇒ Object

Call hooks for different ‘klass`.



233
234
235
236
237
238
# File 'lib/haveapi/hooks.rb', line 233

def call_hooks_as_for(klass, *, **kwargs)
  ret = call_instance_hooks_as_for(klass, *, **kwargs)

  kwargs[:initial] = ret
  call_class_hooks_as_for(klass.class, *, **kwargs)
end

#call_hooks_for(**kwargs) ⇒ Object

Call all instance and class hooks.



215
216
217
218
219
220
# File 'lib/haveapi/hooks.rb', line 215

def call_hooks_for(*, **kwargs)
  ret = call_instance_hooks_for(*, **kwargs)

  kwargs[:initial] = ret
  call_class_hooks_for(*, **kwargs)
end

#call_instance_hooks_as_for(klass) ⇒ Object

Call only instance hooks for different ‘klass`.



241
242
243
# File 'lib/haveapi/hooks.rb', line 241

def call_instance_hooks_as_for(klass, *, **)
  Hooks.call_for(klass, *, **)
end

#call_instance_hooks_for(name, where = nil, args: [], kwargs: {}, 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: [], kwargs: {}, initial: {})
  Hooks.call_for(self, name, where, args:, kwargs:, initial:)
end

#connect_hook(name) ⇒ Object

Connect instance level hook ‘name` to `block`.



251
252
253
# File 'lib/haveapi/hooks.rb', line 251

def connect_hook(name, &)
  Hooks.connect_instance_hook(self, name, &)
end