Module: Og::RelationMacros::ClassMethods
- Defined in:
- lib/og/relation.rb
Instance Method Summary collapse
-
#belongs_to(*args) ⇒ Object
Examples.
-
#has_many(*args) ⇒ Object
Examples.
-
#has_one(*args) ⇒ Object
Examples.
- #inspect_relation(name) ⇒ Object (also: #relation)
- #inspect_relations ⇒ Object (also: #relations)
- #joins_many(*args) ⇒ Object
- #many_to_many(*args) ⇒ Object
-
#refers_to(*args) ⇒ Object
Examples.
Instance Method Details
#belongs_to(*args) ⇒ Object
Examples
belongs_to Article belongs_to :article, Article belongs_to :article, Article, :view => ‘lala’
127 128 129 130 |
# File 'lib/og/relation.rb', line 127 def belongs_to(*args) require 'og/relation/belongs_to' :relations, Og::BelongsTo.new(args, :owner_class => self) end |
#has_many(*args) ⇒ Object
Examples
has_many Comment has_many :comments, Comment
155 156 157 158 |
# File 'lib/og/relation.rb', line 155 def has_many(*args) require 'og/relation/has_many' :relations, Og::HasMany.new(args, :owner_class => self, :collection => true) end |
#has_one(*args) ⇒ Object
Examples
has_one User
145 146 147 148 |
# File 'lib/og/relation.rb', line 145 def has_one(*args) require 'og/relation/has_one' :relations, Og::HasOne.new(args, :owner_class => self) end |
#inspect_relation(name) ⇒ Object Also known as: relation
175 176 177 |
# File 'lib/og/relation.rb', line 175 def inspect_relation(name) [:relations].find { |r| r[:name] == name } end |
#inspect_relations ⇒ Object Also known as: relations
170 171 172 |
# File 'lib/og/relation.rb', line 170 def inspect_relations [:relations] end |
#joins_many(*args) ⇒ Object
160 161 162 163 |
# File 'lib/og/relation.rb', line 160 def joins_many(*args) require 'og/relation/joins_many' :relations, Og::JoinsMany.new(args, :owner_class => self, :collection => true) end |
#many_to_many(*args) ⇒ Object
165 166 167 168 |
# File 'lib/og/relation.rb', line 165 def many_to_many(*args) require 'og/relation/many_to_many' :relations, Og::ManyToMany.new(args, :owner_class => self, :collection => true) end |