module Bmg::Relation::Proxy
This module can be used to create typed collection on top of Bmg
relations. Algebra
methods will be delegated to the decorated relation, and results wrapped in a new instance of the class.
Public Class Methods
new(relation)
click to toggle source
# File lib/bmg/relation/proxy.rb, line 11 def initialize(relation) @relation = relation end
Public Instance Methods
method_missing(name, *args, &bl)
click to toggle source
Calls superclass method
# File lib/bmg/relation/proxy.rb, line 15 def method_missing(name, *args, &bl) if @relation.respond_to?(name) res = @relation.send(name, *args, &bl) res.is_a?(Relation) ? _proxy(res) : res else super end end
respond_to?(name, *args)
click to toggle source
Calls superclass method
# File lib/bmg/relation/proxy.rb, line 24 def respond_to?(name, *args) @relation.respond_to?(name) || super end
to_json(*args, &bl)
click to toggle source
# File lib/bmg/relation/proxy.rb, line 47 def to_json(*args, &bl) @relation.to_json(*args, &bl) end
Protected Instance Methods
_proxy(relation)
click to toggle source
# File lib/bmg/relation/proxy.rb, line 53 def _proxy(relation) self.class.new(relation) end
_proxy_tuple(tuple)
click to toggle source
# File lib/bmg/relation/proxy.rb, line 57 def _proxy_tuple(tuple) tuple end