Module: Except

Defined in:
lib/except.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/except.rb', line 5

def self.included(base)
  class << base
    def find_with_except(*args)
      options = args.last.is_a?(::Hash) ? args.pop : {}
      if exceptions = options.delete(:except)
        options[:select] = (self.column_names - exceptions.split(/\s*,\s*/)).join(", ")
      end
      args << options
      find_without_except(*args)
    end

    alias_method :find_without_except, :find
    alias_method :find, :find_with_except
  end
end