Module: JavaClass::Dsl::JavaNameFactory
- Defined in:
- lib/javaclass/dsl/java_name_factory.rb
Overview
Module to mixin to recognize full qualified Java classnames in Ruby code. Packages have to be suffixed with “.*” to be recognized. This is a bit dangerous, as wrong method or variable names with are a valid country code are not recognized as invalid.
- Author
-
Peter Kofler
Usage
require 'javaclass/dsl/java_name_factory'
include JavaNameFactory
java.lang.String # => "java.lang.String"
java.lang.* # => "java.lang"
Defined Under Namespace
Classes: TemporaryJavaNamePart
Instance Method Summary collapse
-
#__top_level_method_missing__ ⇒ Object
:nodoc:.
-
#java ⇒ Object
Convert the beginning of a full qualified Java classname starting with ‘java’ to a JavaQualifiedName instance.
-
#method_missing(method_id, *args) ⇒ Object
Convert the beginning of a full qualified Java classname to a JavaQualifiedName instance.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args) ⇒ Object
Convert the beginning of a full qualified Java classname to a JavaQualifiedName instance.
31 32 33 34 35 36 37 38 |
# File 'lib/javaclass/dsl/java_name_factory.rb', line 31 def method_missing(method_id, *args) str = method_id.id2name if JavaLanguage::ALLOWED_PACKAGE_PREFIX.include?(str) TemporaryJavaNamePart.new(str) { __top_level_method_missing__(method_id, args) } else __top_level_method_missing__(method_id, args) end end |
Instance Method Details
#__top_level_method_missing__ ⇒ Object
:nodoc:
23 |
# File 'lib/javaclass/dsl/java_name_factory.rb', line 23 alias :__top_level_method_missing__ :method_missing |
#java ⇒ Object
Convert the beginning of a full qualified Java classname starting with ‘java’ to a JavaQualifiedName instance.
26 27 28 |
# File 'lib/javaclass/dsl/java_name_factory.rb', line 26 def java TemporaryJavaNamePart.new('java') { __top_level_method_missing__(:java) } end |