Class: Guacamole::Proxies::Relation

Inherits:
Proxy
  • Object
show all
Defined in:
lib/guacamole/proxies/relation.rb

Instance Method Summary collapse

Methods inherited from Proxy

#init, #method_missing, #respond_to_missing?, #target

Constructor Details

#initialize(model, edge_class, options = {}) ⇒ Relation

Returns a new instance of Relation.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/guacamole/proxies/relation.rb', line 9

def initialize(model, edge_class, options = {})
  responsible_edge_collection = EdgeCollection.for(edge_class)

  direction = options[:inverse] ? :inbound : :outbound

  if options[:just_one]
    init model, -> () { responsible_edge_collection.neighbors(model, direction).to_a.first }
  else
    init model, -> () { responsible_edge_collection.neighbors(model, direction) }
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Guacamole::Proxies::Proxy