Sha256: 965ad05d0fda8290b684f944f5207cadec7959e3270a986c54e9fee95f5eb8bc
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
# encoding: utf-8 module Dynamoid #:nodoc: # The habtm association. module Associations class HasAndBelongsToMany include Dynamoid::Associations::Association def ==(other) records == Array(other) end private def target_association key_name = source.class.to_s.pluralize.downcase.to_sym guess = target_class.associations[key_name] return nil if guess.nil? || guess[:type] != :has_and_belongs_to_many key_name end def associate_target(object) ids = object.send(target_attribute) || Set.new object.update_attribute(target_attribute, ids.merge(Array(source.id))) end def disassociate_target(object) ids = object.send(target_attribute) || Set.new source.update_attribute(source_attribute, ids - Array(source.id)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dynamoid-0.0.2 | lib/dynamoid/associations/has_and_belongs_to_many.rb |