Class: WeThePeople::AssociationProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/we_the_people/association_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, klass) ⇒ AssociationProxy

Returns a new instance of AssociationProxy.



3
4
5
6
# File 'lib/we_the_people/association_proxy.rb', line 3

def initialize(parent, klass)
  @klass = klass
  @parent = parent
end

Instance Method Details

#allObject



20
21
22
# File 'lib/we_the_people/association_proxy.rb', line 20

def all
  cursor.all
end

#cursor(criteria = {}) ⇒ Object



12
13
14
# File 'lib/we_the_people/association_proxy.rb', line 12

def cursor(criteria = {})
  @cursor ||= @klass.cursor(@parent, criteria)
end

#find(id) ⇒ Object



8
9
10
# File 'lib/we_the_people/association_proxy.rb', line 8

def find(id)
  @klass.find(id, @parent)
end

#firstObject



28
29
30
# File 'lib/we_the_people/association_proxy.rb', line 28

def first
  cursor.first
end

#get_allObject



16
17
18
# File 'lib/we_the_people/association_proxy.rb', line 16

def get_all
  cursor.get_all(false)
end

#lengthObject



24
25
26
# File 'lib/we_the_people/association_proxy.rb', line 24

def length
  cursor.length
end