Skip to content

Commit

Permalink
Class#create interop API
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Jan 27, 2012
1 parent 257b3be commit 3813952
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/noscript/runtime.rb
Expand Up @@ -102,6 +102,9 @@ def noscript_def(name, &block)

class Class
noscript_alias [:new]
noscript_def 'create' do |implementation|
Class.new(&implementation)
end
end

class Module
Expand Down
15 changes: 15 additions & 0 deletions test/interop_test.rb
Expand Up @@ -63,4 +63,19 @@ def test_create_ruby_module
assert_respond_to foo, :answer
assert_equal 42, foo.answer
end

def test_create_ruby_clas
kls = compile(<<-CODE)
Ruby.Class.create(->
@def('answer', ->
42
end)
end)
CODE

foo = kls.new

assert_respond_to foo, :answer
assert_equal 42, foo.answer
end
end

0 comments on commit 3813952

Please sign in to comment.