Class: RevisionDiffPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/revision_diff_presenter.rb

Instance Method Summary collapse

Methods inherited from BasePresenter

inherited, #initialize, #to_model, use_presenters

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#change_countObject


11
12
13
# File 'app/presenters/revision_diff_presenter.rb', line 11

def change_count
  @change_count ||= [*changes.values].flatten.size
end

#changesObject


15
16
17
18
19
20
21
22
23
24
# File 'app/presenters/revision_diff_presenter.rb', line 15

def changes
  @changes ||= begin
    map = {'added' => [], 'improved' => [], 'degraded' => [], 'removed' => [], }
    @resource.code_object_diffs.each do |diff|
      map[diff.change] ||= []
      map[diff.change] << diff
    end
    map
  end
end

#code_object(id) ⇒ Object


2
3
4
5
# File 'app/presenters/revision_diff_presenter.rb', line 2

def code_object(id)
  @code_objects ||= {}
  CodeObjectPresenter.new(@code_objects[id] || CodeObject.find(id))
end

#revisionObject


7
8
9
# File 'app/presenters/revision_diff_presenter.rb', line 7

def revision
  @revision ||= RevisionPresenter.new(@resource.after_revision)
end