Module: Kansuu::Util

Included in:
Combinator, Control, Enum, Eq, Flow, Func, Num, Obj, Option, Ord
Defined in:
lib/kansuu/util.rb

Instance Method Summary collapse

Instance Method Details

#__define_func_from_methodObject



4
5
6
7
8
9
10
11
12
# File 'lib/kansuu/util.rb', line 4

def __define_func_from_method
  -> name, method, arity, with_proc = false {
    define_method name, (
      with_proc ?
        -> *a, p, o { o._(method).(*a, &p) } % arity
      : -> *a, o { o._(method).(*a) } % arity
    )
  }
end

#__define_funcs_from_methodObject



14
15
16
# File 'lib/kansuu/util.rb', line 14

def __define_funcs_from_method
  -> hash { hash.each &-> k, v { __define_func_from_method.(k, *v) } }
end

#__module_functionizeObject



18
19
20
# File 'lib/kansuu/util.rb', line 18

def __module_functionize
  -> {instance_methods.map &_.module_function}
end