Sha256: c678992ee1c203837b989f9df4ca5c6b9524c1f68ac87bf55a64325b1d23a0ac
Contents?: true
Size: 730 Bytes
Versions: 6
Compression:
Stored size: 730 Bytes
Contents
# frozen_string_literal: true module Dynamoid # The HasOne association. module Associations # @private class HasOne include Association include SingleAssociation private # Find the target association, always a :belongs_to association. Uses either options[:inverse_of] or the source class name # and default parsing to return the most likely name for the target association. # # @since 0.2.0 def target_association key_name = options[:inverse_of] || source.class.to_s.singularize.underscore.to_sym guess = target_class.associations[key_name] return nil if guess.nil? || guess[:type] != :belongs_to key_name end end end end
Version data entries
6 entries across 6 versions & 1 rubygems