Module: SelfishAssociations::Base::ClassMethods

Defined in:
lib/selfish_associations/base.rb

Instance Method Summary collapse

Instance Method Details

#has_many_selfish(name, scope = nil, **options) ⇒ Object



21
22
23
# File 'lib/selfish_associations/base.rb', line 21

def has_many_selfish(name, scope = nil, **options)
  SelfishAssociations::Builder.new(self).add_association(name, SelfishAssociations::Associations::HasMany.new(name, self, scope, options))
end

#has_one_selfish(name, scope = nil, **options) ⇒ Object



17
18
19
# File 'lib/selfish_associations/base.rb', line 17

def has_one_selfish(name, scope = nil, **options)
  SelfishAssociations::Builder.new(self).add_association(name, SelfishAssociations::Associations::HasOne.new(name, self, scope, options))
end

#selfish_joins(name) ⇒ Object



25
26
27
28
# File 'lib/selfish_associations/base.rb', line 25

def selfish_joins(name)
  assoc = self.selfish_associations[name] or raise SelfishException, "No selfish_associations named #{name} found, perhaps you misspelled it?"
  assoc.join
end