Class: Killbill::Plugin::Creator

Inherits:
Object
  • Object
show all
Defined in:
lib/killbill/creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_class_name) ⇒ Creator

Returns a new instance of Creator.



14
15
16
# File 'lib/killbill/creator.rb', line 14

def initialize(target_class_name)
  @target_class_name = target_class_name
end

Instance Attribute Details

#target_class_nameObject (readonly)

Returns the value of attribute target_class_name.



12
13
14
# File 'lib/killbill/creator.rb', line 12

def target_class_name
  @target_class_name
end

Instance Method Details

#create(services) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/killbill/creator.rb', line 18

def create(services)
  real_class = @target_class_name.to_class

  plugin_delegate = real_class.new
  plugin_delegate.root = services["root"]
  plugin_delegate.logger = services["logger"]
  plugin_delegate.conf_dir = services["conf_dir"]
  plugin_delegate.clock = services["clock"]

  plugin_delegate.plugin_name = extract_plugin_name(plugin_delegate.root)

  # At this point we removed everything from the map which is not API, so we can build the APIs
  # Note: services["kb_apis"] is never nil, except in tests
  kb_apis = KillbillApi.new(@target_class_name, services["kb_apis"] || {})
  plugin_delegate.kb_apis = kb_apis

  plugin_delegate
end