Sha256: 7bc1f1e986e9dc9ba0319d90fd5e88742a59cd5586a0c23efe90b788ab3fa307
Contents?: true
Size: 760 Bytes
Versions: 11
Compression:
Stored size: 760 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, options = {}) case association_type when :belongs_to then BelongsToAssociation.new(document) when :has_many then HasManyAssociation.new(association_name, document, options) when :has_one then HasOneAssociation.new(association_name, document, options) else raise InvalidAssociationError end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems