Class | DataMapper::Associations::Relationship |
In: |
lib/dm-core/associations/relationship.rb
|
Parent: | Object |
OPTIONS | = | [ :child_repository_name, :parent_repository_name, :child_key, :parent_key, :min, :max, :inverse, :reader_visibility, :writer_visibility, :default ].to_set |
child_properties | [R] | @api private |
child_repository_name | [R] |
Repository from where child objects are
loaded
@api semipublic |
instance_variable_name | [R] |
ivar used to store collection of child options in source
@example for :commits association in class VersionControl::Branch # ... has n, :commits end instance variable name for source will be @commits @api semipublic |
max | [R] |
Maximum number of child objects for relationship
@example for :fouls association in class Basketball::Player # ... has 0..5, :fouls end maximum is 5 @api semipublic |
min | [R] |
Minimum number of child objects for relationship
@example for :cores association in class CPU::Multicore # ... has 2..n, :cores end minimum is 2 @api semipublic |
name | [R] |
Relationship name
@example for :parent association in class VersionControl::Commit # ... belongs_to :parent end name is :parent @api semipublic |
options | [R] |
Options used to set up association
of this relationship
@example for :author association in class VersionControl::Commit # ... belongs_to :author, :model => 'Person' end options is a hash with a single key, :model @api semipublic |
parent_properties | [R] | @api private |
parent_repository_name | [R] |
Repository from where parent objects are
loaded
@api semipublic |
query | [R] |
Returns query options for relationship.
For this base class, always returns query options has been initialized with. Overriden in subclasses. @api private |
reader_visibility | [R] |
Returns the visibility for the source accessor
@return [Symbol] the visibility for the accessor added to the source @api semipublic |
writer_visibility | [R] |
Returns the visibility for the source mutator
@return [Symbol] the visibility for the mutator added to the source @api semipublic |
Initializes new Relationship: sets attributes of relationship from options as well as conventions: for instance, @ivar name for association is constructed by prefixing @ to association name.
Once attributes are set, reader and writer are created for the resource association belongs to
@api semipublic
Compares another Relationship for equivalency
@param [Relationship] other
the other Relationship to compare with
@return [Boolean]
true if they are equal, false if not
@api public
Returns a set of keys that identify the target model
@return [PropertySet]
a set of properties that identify the target model
@api semipublic
Returns model class used by child side of the relationship
@return [Resource]
Model for association child
@api private
Eager load the collection using the source as a base
@param [Collection] source
the source collection to query with
@param [Query, Hash] query
optional query to restrict the collection
@return [Collection]
the loaded collection for the source
@api private
Compares another Relationship for equality
@param [Relationship] other
the other Relationship to compare with
@return [Boolean]
true if they are equal, false if not
@api public
Returns the String the Relationship would use in a Hash
@return [String]
String name for the Relationship
@api private
Loads and returns "other end" of the association. Must be implemented in subclasses.
@api semipublic
Gets "other end" of the association directly as @ivar on given resource. Subclasses usually use implementation of this class.
@api semipublic
Returns a set of keys that identify parent model
@return [PropertySet]
a set of properties that identify parent model
@api private
Returns model class used by parent side of the relationship
@return [Resource]
Class of association parent
@api private
Creates and returns Query instance that fetches target resource(s) (ex.: articles) for given target resource (ex.: author)
@api semipublic
Sets value of the "other end" of association on given resource. Must be implemented in subclasses.
@api semipublic
Sets "other end" of the association directly as @ivar on given resource. Subclasses usually use implementation of this class.
@api semipublic
Returns a hash of conditions that scopes query that fetches target object
@return [Hash]
Hash of conditions that scopes query
@api private