Sha256: 7c1404ef16bc9b47ab15b89e49020f52a22eda7857d786e77cd8bc123fe35844

Contents?: true

Size: 540 Bytes

Versions: 31

Compression:

Stored size: 540 Bytes

Contents

#!/usr/bin/env ruby
require 'pp'

class PhonyProc
  def initialize hash
    @data = hash
  end
  def to_proc
    self
  end
  def call lang, *args, &blk
    @data[lang].call(*args, &blk)
  end
end

def with_block something, &block
  pp block
  block.call(:ruby, something)
end

with_block(123, &PhonyProc.new(:ruby => proc { | x | x * 2 },
                               :js => 'function (x) { return x * 2; }'))

=begin

 > ruby lab/phony_proc.rb 
lab/phony_proc.rb:21: PhonyProc#to_proc should return Proc (TypeError)

wah-wah.. :(

=end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
asir-1.2.11 lab/phony_proc.rb
asir-1.2.10 lab/phony_proc.rb
asir-1.2.9 lab/phony_proc.rb
asir-1.2.8 lab/phony_proc.rb
asir-1.2.7 lab/phony_proc.rb
asir-1.2.6 lab/phony_proc.rb
asir-1.2.5 lab/phony_proc.rb
asir-1.2.3 lab/phony_proc.rb
asir-1.2.2 lab/phony_proc.rb
asir-1.2.1 lab/phony_proc.rb
asir-1.2.0 lab/phony_proc.rb
asir-1.1.12 lab/phony_proc.rb
asir-1.1.11 lab/phony_proc.rb
asir-1.1.10 lab/phony_proc.rb
asir-1.1.9 lab/phony_proc.rb
asir-1.1.8 lab/phony_proc.rb
asir-1.1.7 lab/phony_proc.rb
asir-1.1.6 lab/phony_proc.rb
asir-1.1.5 lab/phony_proc.rb
asir-1.1.4 lab/phony_proc.rb