lib/moosex.rb in moosex-0.0.19 vs lib/moosex.rb in moosex-0.0.20

- old
+ new

@@ -13,10 +13,11 @@ require "moosex/attribute" require "moosex/traits" require "weakref" module MooseX + @@PLUGINS = [] @@ALIAS = nil @@MOOSEX_WARNINGS = true @@MOOSEX_FATAL = false def self.warn(x, *c) @@ -38,10 +39,14 @@ if args.has_key?(:meta) && !! args[:meta] @@ALIAS = (args[:meta].is_a?(TrueClass))? :meta : args[:meta] end + if args.has_key?(:with_plugins) + @@PLUGINS = [ args[:with_plugins] ].flatten + end + self end def initialize(*args) if self.respond_to? :BUILDARGS @@ -60,9 +65,14 @@ class_or_module.extend(MooseX::Core) unless class_or_module.respond_to? :__moosex__meta meta = MooseX::Meta.new + @@PLUGINS.each do |plugin| + meta.add_plugin(plugin) + end + @@PLUGINS = [] + class_or_module.define_singleton_method(:__moosex__meta) { meta } if @@ALIAS class_or_module.class_eval do class_or_module.define_singleton_method(@@ALIAS) do