Class: SlowActions::Action

Inherits:
Object
  • Object
show all
Includes:
Computable
Defined in:
lib/slow_actions/slow_actions_action.rb

Overview

Class to hold all #LogEntry objects that are associated with this individual #Action on a #Controller

Instance Attribute Summary collapse

Attributes included from Computable

#db_avg, #db_cost, #db_max, #error_avg, #render_avg, #render_cost, #render_max, #total_avg, #total_cost, #total_max

Instance Method Summary collapse

Methods included from Computable

#compute_times

Constructor Details

#initialize(name, controller) ⇒ Action

Create a new #Action object.

name: the #name of the #Action. i.e. "new"
controller: the #Controller this #Action is a part of


10
11
12
13
14
# File 'lib/slow_actions/slow_actions_action.rb', line 10

def initialize(name, controller)
  @name = name
  @controller = controller
  @log_entries = []
end

Instance Attribute Details

#controllerObject (readonly)

#Controller of this #Action



19
20
21
# File 'lib/slow_actions/slow_actions_action.rb', line 19

def controller
  @controller
end

#log_entriesObject (readonly)

All the #LogEntry objects this #Action holds



27
28
29
# File 'lib/slow_actions/slow_actions_action.rb', line 27

def log_entries
  @log_entries
end

#nameObject (readonly)

Name of this #Action



17
18
19
# File 'lib/slow_actions/slow_actions_action.rb', line 17

def name
  @name
end

Instance Method Details

#add_entry(la) ⇒ Object

Add a log entry to this #Action



22
23
24
25
# File 'lib/slow_actions/slow_actions_action.rb', line 22

def add_entry(la)
  @log_entries << la
  la.action = self
end

#to_sObject



29
30
31
# File 'lib/slow_actions/slow_actions_action.rb', line 29

def to_s
  @name
end