Module: Treat::Proxies::Proxy

Included in:
Array, Numeric, String
Defined in:
lib/treat/proxies/proxy.rb

Overview

Provides a base functionality for proxies.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

Build the entity corresponding to the proxied object and send the method call to the entity.



11
12
13
14
15
16
17
18
# File 'lib/treat/proxies/proxy.rb', line 11

def method_missing(sym, *args, &block)
  if [:do, :apply].include?(sym) || 
    Treat::Workers.lookup(sym)
    to_entity.send(sym, *args)
  else
    super(sym, *args, &block)
  end
end

Instance Method Details

#to_entity(builder = nil) ⇒ Object

Create an unknown type of entity by default.



21
22
23
# File 'lib/treat/proxies/proxy.rb', line 21

def to_entity(builder = nil)
  Treat::Entities::Unknown.new(self.to_s)
end