Module: ActiveRecord::Deselect

Defined in:
lib/active_record/deselect.rb,
lib/active_record/deselect/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Instance Method Details

#deselect(*deselect_columns) ⇒ Object



5
6
7
8
9
# File 'lib/active_record/deselect.rb', line 5

def deselect(*deselect_columns)
  scope = current_scope || relation
  select_columns = filter_columns(scope, deselect_columns)
  scope.except(:select).select(select_columns)
end

#deselect!(*deselect_columns) ⇒ Object



11
12
13
14
15
16
# File 'lib/active_record/deselect.rb', line 11

def deselect!(*deselect_columns)
  scope = current_scope || relation
  select_columns = filter_columns(scope, deselect_columns)
  scope.select_values = select_columns
  scope
end