Class: WatchedExceptionsPresenter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/watchtower/watched_exceptions_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ WatchedExceptionsPresenter

Returns a new instance of WatchedExceptionsPresenter.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/watchtower/watched_exceptions_presenter.rb', line 4

def initialize(params)
  scope = WatchedException
  scope = scope.search("%#{params[:query]}%") if params[:query]
  scope = scope.scoped_by_action_name(params[:action_name]) if params[:action_name]
  scope = scope.scoped_by_controller_name(params[:controller_name]) if params[:controller_name]
  scope = scope.scoped_by_controller_action(params[:controller_action]) if params[:controller_action]
  scope = scope.scoped_by_exception_class(params[:exception_class]) if params[:exception_class]
  scope = scope.scoped({:conditions => ["DATE(#{WatchedException.quoted_table_name}.created_at) >= ?", Date.parse(params[:start_at]).to_s(:db)]}) if params[:start_at]
  scope = scope.scoped({:conditions => ["DATE(#{WatchedException.quoted_table_name}.created_at) <= ?", Date.parse(params[:end_at]).to_s(:db)]}) if params[:end_at]
  @watched_exceptions = scope.paginate(:page => params[:page], :per_page => 10)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(call, *args) ⇒ Object



20
21
22
# File 'lib/watchtower/watched_exceptions_presenter.rb', line 20

def method_missing(call, *args)
  @watched_exceptions.send call, *args
end

Instance Method Details

#each(&block) ⇒ Object



16
17
18
# File 'lib/watchtower/watched_exceptions_presenter.rb', line 16

def each(&block)
  @watched_exceptions.each(&block)
end