Class: CouchbaseOrm::ResultsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase-orm/proxies/results_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(proxyfied) ⇒ ResultsProxy

Returns a new instance of ResultsProxy.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/couchbase-orm/proxies/results_proxy.rb', line 5

def initialize(proxyfied)
    @proxyfied = proxyfied
    
    raise ArgumentError, "Proxyfied object must respond to :to_a" unless @proxyfied.respond_to?(:to_a)

    proxyfied.public_methods.each do |method|
        next if self.public_methods.include?(method)

        self.class.define_method(method) do |*params, &block|
            @proxyfied.send(method, *params, &block)
        end
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



19
20
21
# File 'lib/couchbase-orm/proxies/results_proxy.rb', line 19

def method_missing(m, *args, &block)
    @proxyfied.to_a.send(m, *args, &block)
end