Class: CouchbaseOrm::ResultsProxy
- Inherits:
-
Object
- Object
- CouchbaseOrm::ResultsProxy
- Defined in:
- lib/couchbase-orm/proxies/results_proxy.rb
Instance Method Summary collapse
-
#initialize(proxyfied) ⇒ ResultsProxy
constructor
A new instance of ResultsProxy.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(proxyfied) ⇒ ResultsProxy
Returns a new instance of ResultsProxy.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/couchbase-orm/proxies/results_proxy.rb', line 6 def initialize(proxyfied) @proxyfied = proxyfied raise ArgumentError.new('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
20 21 22 |
# File 'lib/couchbase-orm/proxies/results_proxy.rb', line 20 def method_missing(m, *args, &block) @proxyfied.to_a.send(m, *args, &block) end |