Module: Ludy::Curry

Defined in:
lib/ludy/deprecated/curry.rb

Class Method Summary collapse

Class Method Details

.included(target) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ludy/deprecated/curry.rb', line 7

def self.included target
  target.module_eval{
    instance_methods.each{ |m|
      next unless m =~ /^\w/
      module_eval <<-END
        def c#{m} *args, &block
          if args.size == method(:#{m}).arity
            self.__send__ :#{m}, *args, &block
          else
            method(:c#{m}).to_proc.send :__curry__, *args
          end
        end
      END
    }
  }
end