Module: N::Relation

Includes:
CreateTime, Entity, Sequenced
Defined in:
lib/n/db/mixins.rb

Overview

Relation

Relations between entities.

gmosx: The oid is need in relations too, as a primary key. Another pk could be (pid, pclass, tid, tclass) but this is too big.

Instance Attribute Summary

Attributes included from Managed

#join_fields

Instance Method Summary collapse

Methods included from Sequenced

#initialize

Methods included from CreateTime

#initialize

Methods included from Entity

#__db_pk, #__db_pre_delete, #__db_pre_insert, #initialize, #to_i

Methods included from Managed

#__ancestors_classes, #__db_insert, #__db_pk, #__db_pre_delete, #__db_pre_insert, #__db_update, #__descendants_classes, eval_db_insert, eval_db_read_row, eval_db_update, eval_dbseq, eval_dbtable, #initialize

Instance Method Details

#set_parent(parent, klass = nil) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/n/db/mixins.rb', line 109

def set_parent(parent, klass = nil)
	if parent.is_a?(Fixnum)
		@pid = parent
		@pclass = klass.to_s if klass
	else
		@pid = parent.oid
		@pclass = parent.class.to_s()
	end
end

#set_target(target, klass = nil) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/n/db/mixins.rb', line 119

def set_target(target, klass = nil)
	if target.is_a?(Fixnum)
		@tid = target
		@tclass = klass.to_s if klass
	else
		@tid = target.oid
		@tclass = target.class.to_s()
	end
end