lib/percentable/percentize.rb in percentable-0.0.1 vs lib/percentable/percentize.rb in percentable-0.1.0
- old
+ new
@@ -1,9 +1,13 @@
module Percentable
module Percentize
- def percentize field
- define_method(field) do |args=[]|
- Percent.new(super(*args))
+ def percentize *args
+ options = args.pop if args.last.is_a? Hash
+
+ args.each do |method_name|
+ define_method(method_name) do |args=[]|
+ Percent.new(super(*args) || options[:default])
+ end
end
end
end
end