Class: Ci::BuildTraceChunks::Database

Inherits:
Object
  • Object
show all
Defined in:
app/models/ci/build_trace_chunks/database.rb

Instance Method Summary collapse

Instance Method Details

#append_data(model, new_data, offset) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'app/models/ci/build_trace_chunks/database.rb', line 24

def append_data(model, new_data, offset)
  if offset > 0
    truncated_data = data(model).to_s.byteslice(0, offset)
    new_data = truncated_data + new_data
  end

  set_data(model, new_data)
  model.raw_data.to_s.bytesize
end

#data(model) ⇒ Object


14
15
16
17
18
# File 'app/models/ci/build_trace_chunks/database.rb', line 14

def data(model)
  model.raw_data
rescue ActiveModel::MissingAttributeError
  model.reset.raw_data
end

#delete_data(model) ⇒ Object


38
39
40
# File 'app/models/ci/build_trace_chunks/database.rb', line 38

def delete_data(model)
  model.update_columns(raw_data: nil) unless model.raw_data.nil?
end

#delete_keys(keys) ⇒ Object


10
11
12
# File 'app/models/ci/build_trace_chunks/database.rb', line 10

def delete_keys(keys)
  # no-op
end

#keys(relation) ⇒ Object


6
7
8
# File 'app/models/ci/build_trace_chunks/database.rb', line 6

def keys(relation)
  []
end

#set_data(model, new_data) ⇒ Object


20
21
22
# File 'app/models/ci/build_trace_chunks/database.rb', line 20

def set_data(model, new_data)
  model.raw_data = new_data
end

#size(model) ⇒ Object


34
35
36
# File 'app/models/ci/build_trace_chunks/database.rb', line 34

def size(model)
  data(model).to_s.bytesize
end