Relations domain specific language (DSL). This language defines macros that are used to define relations. Additional macros allow for relation inspection.
Methods
Public Instance methods
Examples
belongs_to :article # inflects Article belongs_to Article # inflects :article belongs_to :article, Article belongs_to :article, Article, :view => 'lala'
[ show source ]
# File lib/og/relation.rb, line 299
299: def belongs_to(*args)
300: require 'og/relation/belongs_to'
301: relations! << Og::BelongsTo.new(args, :owner_class => self)
302: end
Examples
has_many Comment has_many :comments, Comment
[ show source ]
# File lib/og/relation.rb, line 328
328: def has_many(*args)
329: require 'og/relation/has_many'
330: relations! << Og::HasMany.new(args, :owner_class => self, :collection => true)
331: end
Examples
has_one User
[ show source ]
# File lib/og/relation.rb, line 318
318: def has_one(*args)
319: require 'og/relation/has_one'
320: relations! << Og::HasOne.new(args, :owner_class => self)
321: end
[ show source ]
# File lib/og/relation.rb, line 347
347: def inspect_relation(name)
348: relations.find { |r| r[:name] == name }
349: end
..
[ show source ]
# File lib/og/relation.rb, line 335
335: def joins_many(*args)
336: require 'og/relation/joins_many'
337: relations! << Og::JoinsMany.new(args, :owner_class => self, :collection => true)
338: end
..
[ show source ]
# File lib/og/relation.rb, line 342
342: def many_to_many(*args)
343: require 'og/relation/many_to_many'
344: relations! << Og::ManyToMany.new(args, :owner_class => self, :collection => true)
345: end
Examples
refers_to :topic # inflects Topic refers_to Topic # inflects :topic
[ show source ]
# File lib/og/relation.rb, line 309
309: def refers_to(*args)
310: require 'og/relation/refers_to'
311: relations! << Og::RefersTo.new(args, :owner_class => self)
312: end