lib/poolparty/poolparty/plugin_model.rb in auser-poolparty-1.0.0 vs lib/poolparty/poolparty/plugin_model.rb in auser-poolparty-1.1.1
- old
+ new
@@ -10,37 +10,34 @@
def plugins
$plugins ||= {}
end
- class PluginModel
- attr_accessor :name, :klass
- include MethodMissingSugar
- include Configurable
- include PrettyPrinter
+ class PluginModel
+ attr_accessor :klass
def initialize(name,&block)
- @name = name
- # @parent = cld
- class_string_name = "#{name}"
+ symc = "#{name}".top_level_class.camelcase
+ klass = symc.class_constant(PoolParty::Plugin::Plugin, {:preserve => true}, &block)
- # Create the class to evaluate the plugin on the implemented call
- @klass = klass = class_string_name.class_constant(PoolParty::Plugin::Plugin)
- mod = class_string_name.module_constant(&block)
-
- klass.send :include, mod
-
+ lowercase_class_name = symc.downcase
# Store the name of the class for pretty printing later
- klass.name = name
+ # 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
+ meth = <<-EOM
+ def #{lowercase_class_name}(opts={}, &block)
+ i = plugin_store.select {|i| i if i.class == #{lowercase_class_name.camelcase}Class }.first if plugin_store
+ if i
+ i
+ else
+ inst = #{lowercase_class_name.camelcase}Class.new(opts, parent, &block)
+ this_context.plugin_store << inst if this_context
+ inst
end
end
- EOE
+ EOM
+
+ PoolParty::Cloud::Cloud.class_eval meth
end
end
end
\ No newline at end of file