Sha256: 786e7ecd28bb99c2692160ae7bf2bee3488ee3cbb8c0c23cd1ff93e33ab796fc
Contents?: true
Size: 728 Bytes
Versions: 18
Compression:
Stored size: 728 Bytes
Contents
module Mongoid #:nodoc: module Associations #:nodoc: class Factory #:nodoc: # Creates a new association, based on the type provided and # passes the name and document into the newly instantiated # association. # # If the type is invalid a InvalidAssociationError will be thrown. def self.create(association_type, association_name, document) case association_type when :belongs_to then BelongsToAssociation.new(document) when :has_many then HasManyAssociation.new(association_name, document) when :has_one then HasOneAssociation.new(association_name, document) else raise InvalidAssociationError end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems