Sha256: ef3ddef1513729b56d778918ae1999638a078e3a4b34947055a5c40529a76e78

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

require "logtail/util"
require "logtail/event"

module Logtail
  module Events
    # @private
    class ControllerCall < Logtail::Event
      attr_reader :controller, :action, :params, :params_json, :format

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

        if @params
          @params_json = @params.to_json
        end

        @format = attributes[:format]
      end

      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

      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
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
logtail-ruby-0.1.3 lib/logtail/events/controller_call.rb
logtail-0.1.13 lib/logtail/events/controller_call.rb
logtail-0.1.12 lib/logtail/events/controller_call.rb
logtail-0.1.11 lib/logtail/events/controller_call.rb
logtail-0.1.10 lib/logtail/events/controller_call.rb
logtail-0.1.9 lib/logtail/events/controller_call.rb
logtail-0.1.8 lib/logtail/events/controller_call.rb
logtail-0.1.7 lib/logtail/events/controller_call.rb
logtail-0.1.6 lib/logtail/events/controller_call.rb
logtail-0.1.5 lib/logtail/events/controller_call.rb
logtail-0.1.4 lib/logtail/events/controller_call.rb
logtail-0.1.3 lib/logtail/events/controller_call.rb
logtail-0.1.2 lib/logtail/events/controller_call.rb
logtail-0.1.1 lib/logtail/events/controller_call.rb
logtail-0.1.0 lib/logtail/events/controller_call.rb
logtail-ruby-0.1.2 lib/logtail/events/controller_call.rb
logtail-ruby-0.1.1 lib/logtail/events/controller_call.rb
logtail-ruby-0.1.0 lib/logtail/events/controller_call.rb