Module: Marginalia::Comment

Defined in:
lib/marginalia/comment.rb

Class Method Summary collapse

Class Method Details

.clear!Object



47
48
49
# File 'lib/marginalia/comment.rb', line 47

def self.clear!
  self.marginalia_controller = nil
end

.clear_job!Object



51
52
53
# File 'lib/marginalia/comment.rb', line 51

def self.clear_job!
  self.marginalia_job = nil
end

.construct_commentObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/marginalia/comment.rb', line 22

def self.construct_comment
  ret = String.new
  self.components.each do |c|
    component_value = self.send(c)
    if component_value.present?
      ret << "#{c}:#{component_value},"
    end
  end
  ret.chop!
  ret = self.escape_sql_comment(ret)
  ret
end

.construct_inline_commentObject



35
36
37
38
# File 'lib/marginalia/comment.rb', line 35

def self.construct_inline_comment
  return nil if inline_annotations.none?
  escape_sql_comment(inline_annotations.join)
end

.escape_sql_comment(str) ⇒ Object



40
41
42
43
44
45
# File 'lib/marginalia/comment.rb', line 40

def self.escape_sql_comment(str)
  while str.include?('/*') || str.include?('*/')
    str = str.gsub('/*', '').gsub('*/', '')
  end
  str
end

.update!(controller = nil) ⇒ Object



10
11
12
# File 'lib/marginalia/comment.rb', line 10

def self.update!(controller = nil)
  self.marginalia_controller = controller
end

.update_adapter!(adapter) ⇒ Object



18
19
20
# File 'lib/marginalia/comment.rb', line 18

def self.update_adapter!(adapter)
  self.marginalia_adapter = adapter
end

.update_job!(job) ⇒ Object



14
15
16
# File 'lib/marginalia/comment.rb', line 14

def self.update_job!(job)
  self.marginalia_job = job
end