Class: ActiveRecordQueryCounter::Thresholds

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_query_counter/thresholds.rb

Overview

Thresholds for sending notifications based on query time, row count, transaction time, and transaction count.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#query_timeObject

Returns the value of attribute query_time.



7
8
9
# File 'lib/active_record_query_counter/thresholds.rb', line 7

def query_time
  @query_time
end

#row_countObject

Returns the value of attribute row_count.



7
8
9
# File 'lib/active_record_query_counter/thresholds.rb', line 7

def row_count
  @row_count
end

#transaction_countObject

Returns the value of attribute transaction_count.



7
8
9
# File 'lib/active_record_query_counter/thresholds.rb', line 7

def transaction_count
  @transaction_count
end

#transaction_timeObject

Returns the value of attribute transaction_time.



7
8
9
# File 'lib/active_record_query_counter/thresholds.rb', line 7

def transaction_time
  @transaction_time
end

Instance Method Details

#clearObject

Clear all threshold values.



41
42
43
44
45
46
# File 'lib/active_record_query_counter/thresholds.rb', line 41

def clear
  @query_time = nil
  @row_count = nil
  @transaction_time = nil
  @transaction_count = nil
end

#set(values) ⇒ void

This method returns an undefined value.

Set threshold values from a hash.

Parameters:

  • attributes (Hash)

    the attributes to set



29
30
31
32
33
34
35
36
37
38
# File 'lib/active_record_query_counter/thresholds.rb', line 29

def set(values)
  values.each do |key, value|
    setter = "#{key}="
    if respond_to?(setter)
      public_send("#{key}=", value)
    else
      raise ArgumentError, "Unknown threshold: #{key}"
    end
  end
end