Class: Proc

Inherits:
Object show all
Defined in:
lib/engine2/core.rb

Instance Method Summary collapse

Instance Method Details

#chain(&blk) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/engine2/core.rb', line 42

def chain &blk
    prc = self
    lambda do |obj|
        obj.instance_eval(&prc)
        obj.instance_eval(&blk)
    end
end

#chain_args(&blk) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/engine2/core.rb', line 50

def chain_args &blk
    prc = self
    lambda do |*args|
        instance_exec(*args, &prc)
        instance_exec(*args, &blk)
    end
end

#to_jsonObject



37
38
39
40
# File 'lib/engine2/core.rb', line 37

def to_json(*)
    loc = source_location
    loc ? "\"#<Proc:#{loc.first[/\w+.rb/]}:#{loc.last}>\"" : '"source unknown"'
end