Class: Rubyception::Line

Inherits:
Object
  • Object
show all
Defined in:
app/models/rubyception/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Line

Returns a new instance of Line.



6
7
8
9
10
# File 'app/models/rubyception/line.rb', line 6

def initialize(event)
  self.event    = event.name
  self.params   = event.payload
  self.duration = event.duration.to_f.round(2)
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration.



4
5
6
# File 'app/models/rubyception/line.rb', line 4

def duration
  @duration
end

#eventObject

Returns the value of attribute event.



2
3
4
# File 'app/models/rubyception/line.rb', line 2

def event
  @event
end

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'app/models/rubyception/line.rb', line 3

def params
  @params
end

Instance Method Details

#attrsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/rubyception/line.rb', line 12

def attrs
  hook,kind = event.split '.'
  hook      = hook.sub /\?/, ''
  data = {
    kind:     kind,
    hook:     hook,
    duration: duration }

  case "#{kind}_#{hook}".to_sym
    when :action_controller_write_fragment   then params
    when :action_controller_read_fragment    then params
    when :action_controller_expire_fragment  then params
    when :action_controller_exist_fragment   then params
    when :action_controller_write_page       then params
    when :action_controller_expire_page      then params
    when :action_controller_start_processing then params
    when :action_controller_process_action   then params
    when :action_controller_send_file        then params
    when :action_controller_send_data        then params
    when :action_controller_redirect_to      then params
    when :action_controller_halted_callback  then params
    when :action_view_render_template 
      params[:identifier] = remove_root params[:identifier]
    when :action_view_render_partial
      params[:identifier] = remove_root params[:identifier]
    when :active_record_sql                  then params
    when :active_record_identity             then params
    when :action_mailer_receive              then params
    when :action_mailer_deliver              then params
    when :active_resource_request            then params
    when :active_support_cache_read          then params
    when :active_support_cache_generate      then params
    when :active_support_cache_fetch_hit     then params
    when :active_support_cache_write         then params
    when :active_support_cache_delete        then params
    when :active_support_cache_exist         then params
  end
  data.merge! params
end

#remove_root(text) ⇒ Object



52
53
54
# File 'app/models/rubyception/line.rb', line 52

def remove_root text
  text.sub /#{Rails.root}/, ''
end