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


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

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

#available?Boolean

Returns:

  • (Boolean)

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

def available?
  true
end

#data(model) ⇒ Object


18
19
20
# File 'app/models/ci/build_trace_chunks/database.rb', line 18

def data(model)
  model.raw_data
end

#delete_data(model) ⇒ Object


40
41
42
# File 'app/models/ci/build_trace_chunks/database.rb', line 40

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

#delete_keys(keys) ⇒ Object


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

def delete_keys(keys)
  # no-op
end

#keys(relation) ⇒ Object


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

def keys(relation)
  []
end

#set_data(model, new_data) ⇒ Object


22
23
24
# File 'app/models/ci/build_trace_chunks/database.rb', line 22

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

#size(model) ⇒ Object


36
37
38
# File 'app/models/ci/build_trace_chunks/database.rb', line 36

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