Module: FAP::Mixins::Relations::ClassMethods

Defined in:
lib/fap/mixins/relations.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(name, opts = {}) ⇒ Object

Define a “belongs to” relation



56
57
58
59
60
61
# File 'lib/fap/mixins/relations.rb', line 56

def belongs_to name, opts={}
  opts.merge! :type => :belongs_to, :from => self
  relation = FAP::Relation.new name, opts
  self.relations << relation
  define_relation_getter relation
end

#has_many(name, opts = {}) ⇒ Object

Define a “many” relation



46
47
48
49
50
51
# File 'lib/fap/mixins/relations.rb', line 46

def has_many name, opts={}
  opts.merge! :type => :has_many, :from => self
  relation = FAP::Relation.new name, opts
  self.relations << relation
  define_relation_getter relation
end