Sha256: 563e8b227e7e949af0807e7386e713d6062cc7ba9eff3401e4e092985a299630
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
require 'singleton' require 'active_support/core_ext/string/inflections' require 'fulmar/domain/service/configuration_service' module Fulmar module Domain module Service class PluginService include Singleton def self.instance @@instance ||= new end def initialize @plugins = {} config = ConfigurationService.instance.configuration if config.plugins.class == Array fail 'Plugin list must not be an array. Have a look at https://github.com/CORE4/fulmar#plugins for ' + 'more information' end config.plugins.each_pair do |name, plugin_config| puts "Loading plugin '#{name}'..." if config.debug require_plugin(name) @plugins[name] = classname(name, :configuration).new(plugin_config) end end def classname(plugin, name = nil) "Fulmar::Plugin::#{class_map[plugin.to_s.downcase]}#{name.nil? ? '' : '::'+name.to_s.camelize}".constantize end def class_map map = {} Fulmar::Plugin.constants.each do |classname| map[classname.to_s.downcase] = classname.to_s end map end def require_plugin(name) require "fulmar/plugin/#{name}/configuration" end def helpers @plugins.keys.select { |plugin| classname(plugin).constants.include? (:DslHelper) }.collect do |plugin| classname(plugin, :DslHelper) end end def rake_files @plugins.values.collect(&:rake_files).flatten end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fulmar-2.0.1 | lib/fulmar/domain/service/plugin_service.rb |
fulmar-2.0.0 | lib/fulmar/domain/service/plugin_service.rb |