package Rose::DB::Object::Metadata::Relationship::OneToOne; use strict; use Rose::DB::Object::Metadata::Relationship::ManyToOne; our @ISA = qw(Rose::DB::Object::Metadata::Relationship::ManyToOne); our $VERSION = '0.771'; sub type { 'one to one' } sub is_singular { 1 } sub requires_preexisting_parent_object { my($self) = shift; my $meta = $self->parent; my $f_meta = $self->class->meta; my $column_map = $self->column_map; my %pk = map { $_ => 1 } $meta->primary_key_column_names; foreach my $local_column (keys %$column_map) { if($pk{$local_column}) { return $self->{'requires_preexisting_parent_object'} = 1; } } return $self->{'requires_preexisting_parent_object'} = 0; } 1; __END__ =head1 NAME Rose::DB::Object::Metadata::Relationship::OneToOne - One to one table relationship metadata object. =head1 SYNOPSIS use Rose::DB::Object::Metadata::Relationship::OneToOne; $rel = Rose::DB::Object::Metadata::Relationship::OneToOne->new(...); $rel->make_methods(...); ... =head1 DESCRIPTION Objects of this class store and manipulate metadata for relationships in which a single row from one table refers to a single row in another table. This class inherits from L. Inherited methods that are not overridden will not be documented a second time here. See the L documentation for more information. =head1 METHOD MAP =over 4 =item C L, L, ... =item C L, L, C 'get_set_now'> =item C L, L, C 'get_set_on_save'> =item C L, L, C 'delete_now'> =item C L, L, C 'delete_on_save'> =back See the L documentation for an explanation of this method map. =head1 CLASS METHODS =over 4 =item B Get or set the default list of L. TYPES should be a list of relationship method types. Returns the list of default relationship method types (in list context) or a reference to an array of the default relationship method types (in scalar context). The default list contains "get_set_on_save" and "delete_on_save". =back =head1 OBJECT METHODS =over 4 =item B Get or set a reference to a hash that maps local column names to foreign column names. =item B Return a method name for the relationship method type TYPE. For the method types "get_set", "get_set_now", and "get_set_on_save", the relationship's L is returned. For the method types "delete_now" and "delete_on_save", the relationship's L prefixed with "delete_" is returned. Otherwise, undef is returned. =item B Returns true. =item B Get or set the L object to which this object delegates all responsibility. One to one relationships encapsulate essentially the same information as foreign keys. If a foreign key object is stored in this relationship object, then I This includes making object method(s) and adding or modifying the local-to-foreign column map. In other words, if a L is set, the relationship object simply acts as a proxy for the foreign key object. =item B Get or set the name of the L-derived class used to fetch the object. =item B Get or set the name of the L class method to call when fetching the object. =item B Get or set a reference to a hash of name/value arguments to pass to the L when fetching the object. See the documentation for L's L method for a full list of valid arguments for use with the C parameter. =item B If passed a local column name LOCAL, return the corresponding column name in the foreign table. If passed both a local column name LOCAL and a foreign column name FOREIGN, set the local/foreign mapping and return the foreign column name. =item B This method is the mirror image of the L method. Passing a true value to this method is the same thing as setting L to false, and vice versa. Similarly, the return value is the logical negation of L. =item B Get or set a reference to an array of query arguments to add to the L passed to the L when fetching the object. =item B Get or set the boolean value that determines what happens when the local columns in the L have L values, but the object they relate to is not found. If true, a fatal error will occur when the methods that fetch objects through this relationship are called. If false, then the methods will simply return undef. The default is false if one or more of the local columns L or if the local columns in the column map are the same as the L, true otherwise. =item B Returns "one to one". =back =head1 AUTHOR John C. Siracusa (siracusa@gmail.com) =head1 LICENSE Copyright (c) 2009 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.