Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve Type interface
  • Loading branch information
gogotanaka committed Dec 3, 2014
commit cbe7a511c32e0687300f1ec6394a924b7235fdf1
7 changes: 6 additions & 1 deletion lib/java/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def match?(val)

class << self
def define_new(sym, klass, &condition)
type = find_or_create(sym, klass, &condition)
Module.class_eval do
define_method(sym) do |meth|
define_typed_method(meth, Type.find_or_create(sym, klass, &condition))
define_typed_method(meth, type)
end
private sym
end
Expand All @@ -31,5 +32,9 @@ def find(sym)
def find_or_create(sym, klass, &condition)
find(sym) || new(sym, klass, &condition)
end

def types
@@types
end
end
end