Class: Presenters::GroupedPipelineInboxPresenter
- Inherits:
-
Object
- Object
- Presenters::GroupedPipelineInboxPresenter
- Defined in:
- app/models/presenters/grouped_pipeline_inbox_presenter.rb
Constant Summary collapse
- ALL_STATES =
%w[pending hold].freeze
- VISIBLE_STATES =
'pending'
Instance Attribute Summary collapse
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #each_field_header ⇒ Object
-
#each_line ⇒ Object
Yields a line presenter.
- #each_method ⇒ Object
- #field_count ⇒ Object
-
#initialize(pipeline, user, show_held_requests = false) ⇒ GroupedPipelineInboxPresenter
constructor
A new instance of GroupedPipelineInboxPresenter.
- #purpose_important? ⇒ Boolean
- #requests_waiting ⇒ Object
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
#pipeline ⇒ Object (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 |
#user ⇒ Object (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, = {}) fields << [name, method, [:if]] end |
.fields ⇒ Object
5 6 7 |
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 5 def fields @fields ||= [] end |
Instance Method Details
#each_field_header ⇒ Object
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_line ⇒ Object
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_method ⇒ Object
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_count ⇒ Object
68 69 70 |
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 68 def field_count valid_fields.size end |
#purpose_important? ⇒ Boolean
48 49 50 |
# File 'app/models/presenters/grouped_pipeline_inbox_presenter.rb', line 48 def purpose_important? purpose_information? end |
#requests_waiting ⇒ Object
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 |