Class: RTM::AR::TMDM::Construct

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
Movable
Defined in:
lib/rtm/activerecord/tmdm.rb

Direct Known Subclasses

AssociationCache, Reifiable

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Movable

move_all

Class Method Details

.abstract_class?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/rtm/activerecord/tmdm.rb', line 46

def abstract_class?
  self == Construct
end

.alias_ar_relation(new, old) ⇒ Object Also known as: alias_belongs_to, alias_has_many



49
50
51
52
# File 'lib/rtm/activerecord/tmdm.rb', line 49

def alias_ar_relation(new,old)
  alias_method new, old
  alias_method "#{new}=", "#{old}="
end

.belongs_to_parent(parent) ⇒ Object



63
64
65
66
# File 'lib/rtm/activerecord/tmdm.rb', line 63

def belongs_to_parent(parent)
  belongs_to parent
  alias_belongs_to :parent, parent
end

.belongs_to_with_alias(name, synonym) ⇒ Object



55
56
57
58
# File 'lib/rtm/activerecord/tmdm.rb', line 55

def belongs_to_with_alias(name, synonym)
  belongs_to name
  alias_belongs_to synonym, name
end

.has_many_with_alias(name, synonym, *args) ⇒ Object



59
60
61
62
# File 'lib/rtm/activerecord/tmdm.rb', line 59

def has_many_with_alias(name, synonym, *args)
  has_many name, *args
  alias_has_many synonym, name
end

.this_is_a_typed_objectObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rtm/activerecord/tmdm.rb', line 67

def this_is_a_typed_object
  belongs_to :ttype, :class_name => "Topic", :foreign_key => :ttype_id
  module_eval("  def type=(ptype)\n    self.ttype=ptype\n  end\n  def type\n    self.ttype\n  end\n  EOS\nend\n", "(__RTM_AR_TMDM_TYPED_OBJECT__)", 1)

Instance Method Details

#move_to(new_parent) ⇒ Object



83
84
85
# File 'lib/rtm/activerecord/tmdm.rb', line 83

def move_to(new_parent)
  self.parent = new_parent
end

#topic_mapObject



80
81
82
# File 'lib/rtm/activerecord/tmdm.rb', line 80

def topic_map
  parent.topic_map
end