Sha256: 75f565db72f08d21142f4de25823a74cf2d548d59c9b549154cd89f2726dac1e

Contents?: true

Size: 945 Bytes

Versions: 4

Compression:

Stored size: 945 Bytes

Contents

require 'java'

require 'killbill/jkillbill_api'
require 'killbill/killbill_api'

include Java

module Killbill
  module Plugin
    class Creator

      attr_reader :target_class_name

      def initialize(target_class_name)
        @target_class_name = target_class_name
      end

      def create(services)
         japi_proxy = JKillbillApi.new(@target_class_name, services)

         kb_apis = KillbillApi.new(japi_proxy)
         real_class = class_from_string
         plugin_delegate = real_class.new
         plugin_delegate.root = services["root"]
         plugin_delegate.logger = services["logger"]
         plugin_delegate.conf_dir = services["conf_dir"]
         plugin_delegate.kb_apis = kb_apis
         plugin_delegate
      end

      private

      def class_from_string()
        @target_class_name.split('::').inject(Kernel) do |mod, class_name|
          mod.const_get(class_name)
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
killbill-1.0.19 lib/killbill/creator.rb
killbill-1.0.18 lib/killbill/creator.rb
killbill-1.0.17 lib/killbill/creator.rb
killbill-1.0.16 lib/killbill/creator.rb