lib/sugar-high/includes.rb in sugar-high-0.1.8 vs lib/sugar-high/includes.rb in sugar-high-0.2.0
- old
+ new
@@ -1,9 +1,26 @@
require 'active_support/inflector'
-def includes *module_names
- module_names.flatten.each do |name|
- class_eval %{
- include #{name.to_s.camelize}
- }
- end
-end
+class Module
+ def includes *module_names
+ module_names.flatten.each do |name|
+ class_eval %{
+ include #{name.to_s.camelize}
+ }
+ end
+ end
+
+ def extends *module_names
+ module_names.flatten.each do |name|
+ class_eval %{
+ extend #{name.to_s.camelize}
+ }
+ end
+ end
+
+ def includes_and_extends *module_names
+ includes module_names
+ extends module_names
+ end
+
+ alias_method :extends_and_includes, :includes_and_extends
+end
\ No newline at end of file