Module: ColumnsOnDemand::ClassMethods

Defined in:
lib/columns_on_demand.rb

Instance Method Summary collapse

Instance Method Details

#columns_to_load_by_defaultObject



40
41
42
# File 'lib/columns_on_demand.rb', line 40

def columns_to_load_by_default
  @columns_to_load_by_default ||= Set.new(columns.collect(&:name) - columns_to_load_on_demand)
end

#default_select(qualified) ⇒ Object

this is the method API as called by ActiveRecord 2.x. we also call it ourselves above in our ActiveRecord 3 extensions.



31
32
33
34
35
36
37
38
# File 'lib/columns_on_demand.rb', line 31

def default_select(qualified)
  @columns_to_select ||= columns_to_load_by_default.collect {|attr_name| connection.quote_column_name(attr_name)}
  if qualified
    quoted_table_name + '.' + @columns_to_select.join(", #{quoted_table_name}.")
  else
    @columns_to_select.join(", ")
  end
end