Sha256: ff6bf5e7707addb74dff409059844b55981d1d36620c4dd4f2e6cf7d12046f84
Contents?: true
Size: 784 Bytes
Versions: 9
Compression:
Stored size: 784 Bytes
Contents
# encoding: utf-8 module Dynamoid #:nodoc: # The HasOne association. module Associations class HasOne include Dynamoid::Associations::Association def ==(other) target == other end private def target records.first end 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] != :belongs_to key_name end def associate_target(object) object.update_attribute(target_attribute, source.id) end def disassociate_target(object) source.update_attribute(source_attribute, nil) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems