lib/rext/module/helpers.rb in visionmedia-rext-0.1.0 vs lib/rext/module/helpers.rb in visionmedia-rext-0.2.1
- old
+ new
@@ -1,6 +1,8 @@
+require 'rext/object/metaclass'
+
class Module
##
# Shortcut for including an anonymous module.
@@ -46,8 +48,31 @@
else
super
end
end
}
+ end
+
+ ##
+ # Equivalent to defining self.included and
+ # instance evaluating the module passed.
+ #
+ # === Examples
+ #
+ # def self.included mod
+ # mod.instance_eval do
+ # include InstanceMethods
+ # end
+ # end
+ #
+ # setup do
+ # include InstanceMethods
+ # end
+ #
+
+ def setup &block
+ meta_def :included do |mod|
+ mod.instance_eval &block
+ end
end
end
\ No newline at end of file