Module: RubyHooks::Extensible

Included in:
Hook
Defined in:
lib/ruby-hooks/extensible.rb

Overview

Allow extending object with plugins(modules)

Instance Method Summary collapse

Instance Method Details

#add_plugins(method, plugins = nil) ⇒ Object

handle single parameters as well as arrays of params

Parameters:

  • method (Symbol)

    name of the method to call

  • plugins (Object|Array) (defaults to: nil)

    call method for object or every element of array



15
16
17
18
19
20
21
# File 'lib/ruby-hooks/extensible.rb', line 15

def add_plugins(method, plugins = nil)
  case plugins
  when Array then plugins.each { |plugin| send(method, plugin) }
  when nil   then true
  else            send(method, plugins)
  end
end