Class: ProtoJ::Associations::CollectionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/proto_j/associations/collection_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(association) ⇒ CollectionProxy

Returns a new instance of CollectionProxy.



8
9
10
# File 'lib/proto_j/associations/collection_proxy.rb', line 8

def initialize(association)
  @association = association
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



26
27
28
# File 'lib/proto_j/associations/collection_proxy.rb', line 26

def method_missing(method, *args, &block)
  target.send(method, *args, &block)
end

Instance Method Details

#<<(*records) ⇒ Object Also known as: push



21
22
23
# File 'lib/proto_j/associations/collection_proxy.rb', line 21

def <<(*records)
  @association.concat(records) && self
end

#===(other) ⇒ Object



12
13
14
# File 'lib/proto_j/associations/collection_proxy.rb', line 12

def ===(other)
  other === target
end

#to_aryObject Also known as: to_a



16
17
18
# File 'lib/proto_j/associations/collection_proxy.rb', line 16

def to_ary
  target.dup
end