lib/rext/enumerable/helpers.rb in visionmedia-rext-0.1.0 vs lib/rext/enumerable/helpers.rb in visionmedia-rext-0.2.1

- old
+ new

@@ -18,11 +18,13 @@ # === See # # * Enumerable#proxy # - class Proxy < BasicObject + class Proxy + instance_methods.each { |m| undef_method m unless m.match(/^__/) } + def initialize object, meth @object, @method = object, meth end def method_missing meth, *args, &block @@ -67,8 +69,21 @@ # names.every { length > 4 }.all? # => true # def every &block block ? proxy(:map).instance_eval(&block) : proxy(:map) + end + + ## + # Check if all +args+ are included. + # + # === Examples + # + # permissions = 'save', 'edit', 'delete' + # permissions.includes_all? 'save', 'edit' # => true + # + + def includes_all? *args + args.all? { |arg| include? arg } end end