Class: Presenters::GroupedPipelineInboxPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/models/presenters/grouped_pipeline_inbox_presenter.rb

Overview

rubocop:todo Style/Documentation

Constant Summary collapse

ALL_STATES =
%w[pending hold].freeze
VISIBLE_STATES =
'pending'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline, user, show_held_requests = false) ⇒ GroupedPipelineInboxPresenter

Returns a new instance of GroupedPipelineInboxPresenter.


33
34
35
36
37
38
39
40
41
42
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 33

def initialize(pipeline, user, show_held_requests = false)
  @pipeline = pipeline
  @user = user
  @show_held_requests = show_held_requests

  # We shouldn't trigger this, as we explicitly detect the group by status
  unless pipeline.group_by_parent?
    raise "Pipeline #{pipeline.name} is incompatible with GroupedPipelineInboxPresenter"
  end
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.


29
30
31
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 29

def pipeline
  @pipeline
end

#userObject (readonly)

Returns the value of attribute user.


29
30
31
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 29

def user
  @user
end

Class Method Details

.add_field(name, method, options = {}) ⇒ Object


9
10
11
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 9

def add_field(name, method, options = {})
  fields << [name, method, options[:if]]
end

.fieldsObject


5
6
7
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 5

def fields
  @fields ||= []
end

Instance Method Details

#each_field_headerObject


52
53
54
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 52

def each_field_header
  valid_fields.each { |field, _method, _condition| yield field }
end

#each_lineObject

Yields a line presenter


61
62
63
64
65
66
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 61

def each_line
  grouped_requests.each_with_index do |request, index|
    group = [request.labware_id, request.submission_id]
    yield GroupLinePresenter.new(group, request, index, pipeline, self)
  end
end

#each_methodObject


56
57
58
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 56

def each_method
  valid_fields.each { |_field, method, _condition| yield method }
end

#field_countObject


68
69
70
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 68

def field_count
  valid_fields.size
end

#purpose_important?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 48

def purpose_important?
  purpose_information?
end

#requests_waitingObject


44
45
46
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 44

def requests_waiting
  @pipeline.requests.unbatched.where(state: ALL_STATES).count
end