Class: Checkoff::CustomFieldValueFunctionEvaluator

Inherits:
FunctionEvaluator show all
Defined in:
lib/checkoff/internal/task_selector_evaluator.rb

Overview

:custom_field_value function

Instance Method Summary collapse

Methods inherited from FunctionEvaluator

#initialize

Constructor Details

This class inherits a constructor from Checkoff::FunctionEvaluator

Instance Method Details

#evaluate(task, custom_field_name) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/checkoff/internal/task_selector_evaluator.rb', line 149

def evaluate(task, custom_field_name)
  custom_fields = task.custom_fields
  if custom_fields.nil?
    raise "custom fields not found on task - did you add 'custom_field' in your extra_fields argument?"
  end

  custom_field = custom_fields.find { |field| field.fetch('name') == custom_field_name }
  return nil if custom_field.nil?

  custom_field['display_value']
end

#evaluate_arg?(_index) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/checkoff/internal/task_selector_evaluator.rb', line 145

def evaluate_arg?(_index)
  false
end

#matches?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/checkoff/internal/task_selector_evaluator.rb', line 141

def matches?
  fn?(task_selector, :custom_field_value)
end