Class: ScoutApm::SqlList

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/instruments/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql = nil) ⇒ SqlList

Returns a new instance of SqlList.



7
8
9
10
11
12
13
# File 'lib/scout_apm/instruments/active_record.rb', line 7

def initialize(sql=nil)
  @sqls = []

  if !sql.nil?
    push(sql)
  end
end

Instance Attribute Details

#sqlsObject (readonly)

Returns the value of attribute sqls.



5
6
7
# File 'lib/scout_apm/instruments/active_record.rb', line 5

def sqls
  @sqls
end

Instance Method Details

#<<(sql) ⇒ Object



15
16
17
# File 'lib/scout_apm/instruments/active_record.rb', line 15

def <<(sql)
  push(sql)
end

#merge(other) ⇒ Object

All of this one, then all of the other.



27
28
29
# File 'lib/scout_apm/instruments/active_record.rb', line 27

def merge(other)
  @sqls += other.sqls
end

#push(sql) ⇒ Object



19
20
21
22
23
24
# File 'lib/scout_apm/instruments/active_record.rb', line 19

def push(sql)
  if !(Utils::SqlSanitizer === sql)
    sql = Utils::SqlSanitizer.new(sql)
  end
  @sqls << sql
end

#to_sObject



31
32
33
# File 'lib/scout_apm/instruments/active_record.rb', line 31

def to_s
  @sqls.map{|s| s.to_s }.join(";\n")
end