Sha256: 156fb5fad50a0e8b9b08e9a7d1688ad7bae57bff2be9fe0c7fb5d6553dda4195

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module InfluxDB
  module Rails
    class Context
      def controller
        Thread.current[:_influxdb_rails_controller]
      end

      def controller=(value)
        Thread.current[:_influxdb_rails_controller] = value
      end

      def action
        Thread.current[:_influxdb_rails_action]
      end

      def action=(value)
        Thread.current[:_influxdb_rails_action] = value
      end

      def request_id=(value)
        Thread.current[:_influxdb_rails_request_id] = value
      end

      def request_id
        Thread.current[:_influxdb_rails_request_id]
      end

      def location
        [
          controller,
          action,
        ].reject(&:blank?).join("#")
      end

      def reset
        Thread.current[:_influxdb_rails_controller] = nil
        Thread.current[:_influxdb_rails_action] = nil
        Thread.current[:_influxdb_rails_tags] = nil
        Thread.current[:_influxdb_rails_values] = nil
        Thread.current[:_influxdb_rails_request_id] = nil
      end

      def tags
        Thread.current[:_influxdb_rails_tags] || {}
      end

      def tags=(tags)
        Thread.current[:_influxdb_rails_tags] = tags
      end

      def values
        Thread.current[:_influxdb_rails_values].to_h.merge(request_id: request_id)
      end

      def values=(values)
        Thread.current[:_influxdb_rails_values] = values
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
influxdb-rails-1.0.0 lib/influxdb/rails/context.rb
influxdb-rails-1.0.0.beta4 lib/influxdb/rails/context.rb