Class: Logtail::Events::ControllerCall

Inherits:
Logtail::Event show all
Defined in:
lib/logtail/events/controller_call.rb

Instance Attribute Summary collapse

Attributes inherited from Logtail::Event

#metadata

Instance Method Summary collapse

Methods inherited from Logtail::Event

#inspect, #to_json, #to_msgpack, #to_s

Constructor Details

#initialize(attributes) ⇒ ControllerCall

Returns a new instance of ControllerCall.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/logtail/events/controller_call.rb', line 10

def initialize(attributes)
  @controller = attributes[:controller]
  @action = attributes[:action]
  @params = attributes[:params]

  if @params
    @params_json = @params.to_json
  end

  @format = attributes[:format]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



8
9
10
# File 'lib/logtail/events/controller_call.rb', line 8

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



8
9
10
# File 'lib/logtail/events/controller_call.rb', line 8

def controller
  @controller
end

#formatObject (readonly)

Returns the value of attribute format.



8
9
10
# File 'lib/logtail/events/controller_call.rb', line 8

def format
  @format
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/logtail/events/controller_call.rb', line 8

def params
  @params
end

#params_jsonObject (readonly)

Returns the value of attribute params_json.



8
9
10
# File 'lib/logtail/events/controller_call.rb', line 8

def params_json
  @params_json
end

Instance Method Details

#messageObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/logtail/events/controller_call.rb', line 22

def message
  message = "Processing by #{controller}##{action}"
  if !message.nil?
    message << " as #{format}"
  end
  if !params.nil? && params.length > 0
    message << "\n  Parameters: #{params.inspect}"
  end
  message
end

#to_hashObject



33
34
35
36
37
38
39
40
41
# File 'lib/logtail/events/controller_call.rb', line 33

def to_hash
  {
    controller_called: Util::NonNilHashBuilder.build do |h|
      h.add(:controller, controller)
      h.add(:action, action)
      h.add(:params_json, params_json)
    end
  }
end