Module: Perry::Associations::External::ClassMethods

Defined in:
lib/perry/associations/external.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(id, options = {}) ⇒ Object



9
10
11
# File 'lib/perry/associations/external.rb', line 9

def belongs_to(id, options={})
  create_external_association Perry::Association::BelongsTo.new(self, id, options)
end

#has_many(id, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/perry/associations/external.rb', line 17

def has_many(id, options={})
  klass = if options.include?(:through)
    Perry::Association::HasManyThrough
  else
    Perry::Association::HasMany
  end
  create_external_association klass.new(self, id, options)
end

#has_one(id, options = {}) ⇒ Object



13
14
15
# File 'lib/perry/associations/external.rb', line 13

def has_one(id, options={})
  create_external_association Perry::Association::HasOne.new(self, id, options)
end