Sha256: 5515d30035c0a41deaef214a12a1a979beb7a8719430f2a73ca41d69468754ad

Contents?: true

Size: 2 KB

Versions: 4

Compression:

Stored size: 2 KB

Contents

module Ecoportal
  module API
    class V2
      class Pages
        class PageStage
          class Tasks < Common::Content::CollectionModel
            class_resolver :task_class, "Ecoportal::API::V2::Pages::PageStage::Task"

            self.klass = :task_class

            def ooze
              self._parent.ooze
            end

            # @return [Ecoportal::API::V2::Pages::PageStage::Task]
            def get_by_id(id)
              self.find do |task|
                task.id == id
              end
            end

            # @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
            def get_by_type(type)
              select do |task|
                task.type == type
              end
            end

            # @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
            def open(&block)
              reject(&:complete).tap do |res|
                res.each(&block)
              end
            end

            # @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
            def complete(&block)
              select(&:complete).tap do |res|
                res.each(&block)
              end
            end

            # @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
            def fill_in(active: :unused, &block)
              target = self
              target = open     if active == true
              target = complete if active == false

              target.select(&:fill_in?).tap do |res|
                res.each(&block)
              end
            end

            # @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
            def review(active: :unused, &block)
              target = self
              target = open     if active == true
              target = complete if active == false

              target.select(&:review?).tap do |res|
                res.each(&block)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.6 lib/ecoportal/api/v2/pages/page_stage/tasks.rb
ecoportal-api-v2-2.0.5 lib/ecoportal/api/v2/pages/page_stage/tasks.rb
ecoportal-api-v2-2.0.4 lib/ecoportal/api/v2/pages/page_stage/tasks.rb
ecoportal-api-v2-2.0.3 lib/ecoportal/api/v2/pages/page_stage/tasks.rb