Module: SupportTable::BelongsToSupportTable::ClassMethods

Defined in:
lib/support_table/belongs_to_support_table.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to_support_table(name, *args, **kwargs) ⇒ void

This method returns an undefined value.

Define a belongs_to association that references a support table. This method takes the same arguments as belongs_to. It will add a caching layer to the association to minimize database queries.

Parameters:

  • name (Symbol)

    The name of the association.

  • args (Array)

    Additional arguments to pass to belongs_to.

  • kwargs (Hash)

    Additional keyword arguments to pass to belongs_to.



18
19
20
21
22
23
24
25
26
# File 'lib/support_table/belongs_to_support_table.rb', line 18

def belongs_to_support_table(name, *args, **kwargs)
  unless include?(SupportTableCache::Associations)
    include SupportTableCache::Associations
  end

  retval = belongs_to name, *args, **kwargs
  cache_belongs_to name
  retval
end