summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-method/mrblib/method.rb
blob: f7cefa2e562974407ca66e2b6d16cbf7320d7c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Method
  def to_proc
    m = self
    lambda { |*args, &b|
      m.call(*args, &b)
    }
  end

  def owner
    @owner
  end

  def receiver
    @recv
  end

  def name
    @name
  end

  def <<(other)
    ->(*args, &block) { call(other.call(*args, &block)) }
  end

  def >>(other)
    ->(*args, &block) { other.call(call(*args, &block)) }
  end
end