Module: Watchtower::WatchedExceptionBase::Scopes

Defined in:
lib/watchtower/watched_exception_base.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/watchtower/watched_exception_base.rb', line 39

def self.included(base)
  base.class_eval do
    default_scope :order => "#{WatchedException.quoted_table_name}.created_at DESC"
    named_scope :recent, lambda {|*ct| ct = ct.first || 5; { :limit => ct }}
    named_scope :search, lambda {|query| {
      :conditions => [
        [ :controller_name, :action_name, 
          :controller_action, :exception_class, 
          :parameters, :message].map {|attribute| "#{WatchedException.quoted_table_name}.#{attribute} LIKE :query"}.join(" OR "), {:query => query}
        ]
    }}
    
  end
end