Sha256: 59d44c61d1f5fff044cebd67067c6b0023e805f3550b4d761e6968df615a9072

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'java'
require 'pathname'

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)
        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
        kb_apis = KillbillApi.new(@target_class_name, services["kb_apis"])
        plugin_delegate.kb_apis = kb_apis

        plugin_delegate
      end


      private

      def extract_plugin_name(root)
        p = Pathname.new(root)
        p.split[0].split[-1].to_s
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
killbill-6.3.0 lib/killbill/creator.rb
killbill-6.2.0 lib/killbill/creator.rb