Class: WorkItems::TypesFinder
- Inherits:
-
Object
- Object
- WorkItems::TypesFinder
- Defined in:
- app/finders/work_items/types_finder.rb
Instance Method Summary collapse
- #execute(name: nil, only_available: false) ⇒ Object
-
#initialize(container:) ⇒ TypesFinder
constructor
A new instance of TypesFinder.
Constructor Details
#initialize(container:) ⇒ TypesFinder
Returns a new instance of TypesFinder.
5 6 7 |
# File 'app/finders/work_items/types_finder.rb', line 5 def initialize(container:) @container = container end |
Instance Method Details
#execute(name: nil, only_available: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/finders/work_items/types_finder.rb', line 9 def execute(name: nil, only_available: false) return WorkItems::Type.none if unavailable_container? return order(WorkItems::Type.by_type(name)) if name.present? && !only_available return order(WorkItems::Type) unless only_available ::WorkItems::TypesFilter .new(container: @container) .allowed_types .then { |types| name.present? ? types.intersection(Array.wrap(name)) : types } .then { |types| WorkItems::Type.by_type(types) } .then { |scope| order(scope) } end |