Class Linguistics::LanguageProxyClass
In: lib/linguistics.rb  (CVS)
Parent: Object

A class which is inherited from by proxies for classes being extended with one or more linguistic interfaces. It provides on-the-fly creation of linguistic methods when the :installProxy option is passed to the call to Linguistics#use.

Methods

Attributes

langmod  [RW] 

Public Class methods

Create a new LanguageProxy for the given receiver.

[Source]

# File lib/linguistics.rb, line 72
        def initialize( receiver )
            @receiver = receiver
        end

Public Instance methods

Returns a human-readable representation of the languageProxy for debugging, logging, etc.

[Source]

# File lib/linguistics.rb, line 104
        def inspect
            "<%s languageProxy for %s object %s>" % [
                self.class.langmod.language,
                @receiver.class.name,
                @receiver.inspect,
            ]
        end

Autoload linguistic methods defined in the module this object’s class uses for inflection.

[Source]

# File lib/linguistics.rb, line 89
        def method_missing( sym, *args, &block )
            return super unless self.class.langmod.respond_to?( sym )

            self.class.module_eval %{
                def #{sym}( *args, &block )
                    self.class.langmod.#{sym}( @receiver, *args, &block )
                end
            }, "{Autoloaded: " + __FILE__ + "}", __LINE__

            self.method( sym ).call( *args, &block )
        end

Overloaded to take into account the proxy method.

[Source]

# File lib/linguistics.rb, line 82
        def respond_to?( sym )
            self.class.langmod.respond_to?( sym ) || super
        end

[Validate]