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

Constructor Details

#initializeThresholds

Returns a new instance of Thresholds.



9
10
11
# File 'lib/active_record_query_counter/thresholds.rb', line 9

def initialize
  clear
end

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.



45
46
47
48
49
50
# File 'lib/active_record_query_counter/thresholds.rb', line 45

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



33
34
35
36
37
38
39
40
41
42
# File 'lib/active_record_query_counter/thresholds.rb', line 33

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