Class: GitlabJanitor::ImageCleaner::Model

Inherits:
BaseCleaner::Model show all
Defined in:
lib/gitlab_janitor/image_cleaner.rb

Instance Attribute Summary collapse

Attributes inherited from BaseCleaner::Model

#model

Instance Method Summary collapse

Methods inherited from BaseCleaner::Model

#method_missing, #respond_to?, #respond_to_missing?

Constructor Details

#initialize(model, name, store) ⇒ Model

Returns a new instance of Model.



11
12
13
14
15
16
17
# File 'lib/gitlab_janitor/image_cleaner.rb', line 11

def initialize(model, name, store)
  super(model)
  @store = store
  @name = name

  info['_Age'] = (Time.now - Time.at(loaded_at)).round(0)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GitlabJanitor::BaseCleaner::Model

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



9
10
11
# File 'lib/gitlab_janitor/image_cleaner.rb', line 9

def store
  @store
end

Instance Method Details

#ageObject



27
28
29
# File 'lib/gitlab_janitor/image_cleaner.rb', line 27

def age
  info['_Age']
end

#age_textObject



31
32
33
# File 'lib/gitlab_janitor/image_cleaner.rb', line 31

def age_text
  Fugit::Duration.parse(age).deflate.to_plain_s
end

#idObject



35
36
37
# File 'lib/gitlab_janitor/image_cleaner.rb', line 35

def id
  info['id']
end

#loaded_atObject



19
20
21
# File 'lib/gitlab_janitor/image_cleaner.rb', line 19

def loaded_at
  store.image(self)[:loaded_at]
end

#nameObject



23
24
25
# File 'lib/gitlab_janitor/image_cleaner.rb', line 23

def name
  @name || id
end