Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (25 sloc) 0.631 kb
module ActiveResource
module Associations
class AssociationCollection < Array
def initialize(array, host_resource, association_col)
@host_resource = host_resource
@association_col = association_col
self.concat array
end
def <<(member)
member.send "#{@association_col}=", @host_resource.id
member.save
super(member)
end
def delete(member)
member.send "#{@association_col}=", nil
member.save
super(member)
end
def clear
self.each{|member| delete(member)}
super
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.