Sha256: f86c625fcb2d3ccac8e9ed8ccbf0591b8c20d868ffa89baec3c5adf5366a3bdc

Contents?: true

Size: 1.78 KB

Versions: 86

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

86 entries across 86 versions & 1 rubygems

Version Path
checkoff-0.161.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.160.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.159.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.158.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.157.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.156.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.155.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.154.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.153.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.152.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.151.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.150.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.149.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.148.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.147.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.145.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.139.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.138.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.137.0 lib/checkoff/internal/task_selector_evaluator.rb
checkoff-0.136.0 lib/checkoff/internal/task_selector_evaluator.rb