Move eraseable implementation to build concern
This commit is contained in:
parent
9972abc295
commit
f6a91ccc5b
4 changed files with 17 additions and 47 deletions
|
@ -35,10 +35,9 @@
|
|||
|
||||
module Ci
|
||||
class Build < CommitStatus
|
||||
include Compoundable
|
||||
component :eraseable, Gitlab::Ci::Build::Eraseable
|
||||
|
||||
include Gitlab::Application.routes.url_helpers
|
||||
include Eraseable
|
||||
|
||||
LAZY_ATTRIBUTES = ['trace']
|
||||
|
||||
belongs_to :runner, class_name: 'Ci::Runner'
|
||||
|
|
15
app/models/ci/build/eraseable.rb
Normal file
15
app/models/ci/build/eraseable.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Ci
|
||||
class Build
|
||||
module Eraseable
|
||||
include ActiveSupport::Concern
|
||||
|
||||
def erase!
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def erased?
|
||||
raise NotImpementedError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
module Compoundable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
private
|
||||
|
||||
def component(name, klass)
|
||||
define_method(name) do
|
||||
component_object = instance_variable_get("@#{name}")
|
||||
return component_object if component_object
|
||||
instance_variable_set("@#{name}", klass.new(self))
|
||||
end
|
||||
|
||||
klass.instance_methods(false).each do |method|
|
||||
delegate method, to: name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
module Gitlab
|
||||
module Ci
|
||||
module Build
|
||||
class Eraseable
|
||||
def initialize(build)
|
||||
@build = build
|
||||
end
|
||||
|
||||
def erase!
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def erased?
|
||||
@build.artifacts_file.exists? && @build.artifacts_metadata.exists?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def trace_file
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue