Module: Bmg::Relation::Proxy

Defined in:
lib/bmg/relation/proxy.rb

Overview

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.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &bl) ⇒ Object



15
16
17
18
19
20
21
22
# 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

Instance Method Details

#initialize(relation) ⇒ Object



11
12
13
# File 'lib/bmg/relation/proxy.rb', line 11

def initialize(relation)
  @relation = relation
end

#respond_to?(name, *args) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bmg/relation/proxy.rb', line 24

def respond_to?(name, *args)
  @relation.respond_to?(name) || super
end

#to_json(*args, &bl) ⇒ Object



47
48
49
# File 'lib/bmg/relation/proxy.rb', line 47

def to_json(*args, &bl)
  @relation.to_json(*args, &bl)
end