Sha256: 21d39156d28183168d4c9230ecf99dbca436087abd24fa1e34a38852f4faf344
Contents?: true
Size: 1.39 KB
Versions: 12
Compression:
Stored size: 1.39 KB
Contents
require File.join(File.dirname(__FILE__), "resource") module PoolParty module PluginModel def plugin(name=:plugin, cloud=nil, &block) plugins.has_key?(name) ? plugins[name] : (plugins[name] = PluginModel.new(name, cloud, &block)) end alias_method :register_plugin, :plugin def plugins $plugins ||= {} end class PluginModel attr_accessor :name, :klass include MethodMissingSugar include Configurable include PrettyPrinter def initialize(name,cld,&block) @name = name # @parent = cld class_string_name = "#{name}" # Create the class to evaluate the plugin on the implemented call klass = class_string_name.class_constant(PoolParty::Plugin::Plugin) mod = class_string_name.module_constant(&block) klass.send :include, mod # Store the name of the class for pretty printing later klass.name = name # Add the plugin definition to the cloud as an instance method PoolParty::Cloud::Cloud.class_eval <<-EOE def #{name}(parent=self, &block) @pa = parent @#{class_string_name.downcase} ||= returning #{class_string_name.class_constant}.new(parent, &block) do |pl| @pa.plugin_store << pl end end EOE end end end end
Version data entries
12 entries across 12 versions & 2 rubygems