Sha256: f86c625fcb2d3ccac8e9ed8ccbf0591b8c20d868ffa89baec3c5adf5366a3bdc

Contents?: true

Size: 1.78 KB

Versions: 89

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require_relative 'selector_classes/common'
require_relative 'selector_classes/task'
require_relative 'selector_evaluator'

module Checkoff
  # Evaluates task selectors against a task
  class TaskSelectorEvaluator < SelectorEvaluator
    # @param task [Asana::Resources::Task]
    # @param tasks [Checkoff::Tasks]
    # @param timelines [Checkoff::Timelines]
    # @param custom_fields [Checkoff::CustomFields]
    def initialize(task:,
                   tasks: Checkoff::Tasks.new,
                   timelines: Checkoff::Timelines.new,
                   custom_fields: Checkoff::CustomFields.new)
      @item = task
      @tasks = tasks
      @timelines = timelines
      @custom_fields = custom_fields
      super()
    end

    private

    COMMON_FUNCTION_EVALUATORS = (Checkoff::SelectorClasses::Common.constants.map do |const|
      Checkoff::SelectorClasses::Common.const_get(const)
    end - [Checkoff::SelectorClasses::Common::FunctionEvaluator]).freeze

    TASK_FUNCTION_EVALUATORS = (Checkoff::SelectorClasses::Task.constants.map do |const|
      Checkoff::SelectorClasses::Task.const_get(const)
    end - [Checkoff::SelectorClasses::Task::FunctionEvaluator]).freeze

    FUNCTION_EVALUTORS = (COMMON_FUNCTION_EVALUATORS + TASK_FUNCTION_EVALUATORS).freeze

    # @return [Array<Class<TaskSelectorClasses::FunctionEvaluator>>]
    def function_evaluators
      FUNCTION_EVALUTORS
    end

    # @return [Hash]
    def initializer_kwargs
      { tasks: tasks, timelines: timelines, custom_fields: custom_fields }
    end

    # @return [Asana::Resources::Task]
    attr_reader :item
    # @return [Checkoff::Tasks]
    attr_reader :tasks
    # @return [Checkoff::Timelines]
    attr_reader :timelines
    # @return [Checkoff::CustomFields]
    attr_reader :custom_fields
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
checkoff-0.205.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.204.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.203.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.201.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.200.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.199.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.198.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.197.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.196.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.195.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.194.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.193.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.192.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.191.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.190.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.189.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.188.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.187.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.186.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.185.0 lib/checkoff/internal/task_selector_evaluator.rb