Class: CacheKeyDependencies

Inherits:
Object
  • Object
show all
Defined in:
app/interactors/cache_key_dependencies.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ CacheKeyDependencies

Returns a new instance of CacheKeyDependencies.



15
16
17
# File 'app/interactors/cache_key_dependencies.rb', line 15

def initialize(project)
  @project = ProjectDependencies.new(project)
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



2
3
4
# File 'app/interactors/cache_key_dependencies.rb', line 2

def project
  @project
end

Class Method Details

.for(*projects) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'app/interactors/cache_key_dependencies.rb', line 4

def self.for(*projects)
  projects = projects[0] if projects.length == 1 && projects[0].respond_to?(:each)
  projects.each do |project|
    begin
      self.new(project).perform!
    rescue StandardError => e
      Houston.report_exception(e)
    end
  end
end

Instance Method Details

#perform!Object



19
20
21
22
23
24
25
26
# File 'app/interactors/cache_key_dependencies.rb', line 19

def perform!
  KeyDependency.all.each do |dependency|
    version = ProjectDependency.new(project, dependency).version
    project.extended_attributes = project.extended_attributes.merge(
      "key_dependency.#{dependency.slug}" => version)
  end
  project.update_column :extended_attributes, project.extended_attributes
end