Class: Rundock::HookFactory
Constant Summary collapse
- HookNotImplementedError =
Class.new(NotImplementedError)
Class Method Summary collapse
Instance Method Summary collapse
- #create(name, attributes) ⇒ Object
-
#initialize(type) ⇒ HookFactory
constructor
A new instance of HookFactory.
Constructor Details
#initialize(type) ⇒ HookFactory
Returns a new instance of HookFactory.
9 10 11 |
# File 'lib/rundock/hook_factory.rb', line 9 def initialize(type) @type = type end |
Class Method Details
.instance(type) ⇒ Object
5 6 7 |
# File 'lib/rundock/hook_factory.rb', line 5 def self.instance(type) self.new(type) end |
Instance Method Details
#create(name, attributes) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rundock/hook_factory.rb', line 13 def create(name, attributes) klass = "Rundock::Hook::#{@type.to_s.to_camel_case}" Logger.debug("initialize #{klass} hook") raise HookNotImplementedError unless Rundock::Hook::Base.subclasses.map(&:to_s).include?(klass) obj = nil klass.split('::').map do |k| obj = if obj.nil? Kernel.const_get(k) else obj = obj.const_get(k) end end hook = obj.new(name, attributes) hook end |