class MARC::Spec::Queries::QueryExecutor

Attributes

cache[R]
marc_record[R]
root_query[R]

Public Class Methods

new(marc_record, root_query, cache = {}) click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 12
def initialize(marc_record, root_query, cache = {})
  @marc_record = ensure_type(marc_record, MARC::Record)
  @root_query = root_query
  @cache = cache
end

Public Instance Methods

any_results?() click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 30
def any_results?
  root_query.any_results?(self, root_fields)
end
apply_selector(selector, field) click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 38
def apply_selector(selector, field)
  return [field] unless selector

  cache_key = [selector, field]
  cache[cache_key] ||= selector.apply(field)
end
apply_tag(tag) click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 34
def apply_tag(tag)
  cache[tag] ||= tag.apply(marc_record)
end
condition_met?(condition, context_field, context_result) click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 45
def condition_met?(condition, context_field, context_result)
  cond_ctx = ConditionContext.new(context_field, context_result, self)
  condition.met?(cond_ctx)
end
execute() click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 26
def execute
  root_query.execute(self, root_fields)
end
root_fields() click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 22
def root_fields
  @root_fields ||= apply_tag(root_tag)
end
root_tag() click to toggle source
# File lib/marc/spec/queries/query_executor.rb, line 18
def root_tag
  @root_tag ||= root_query.tag || Tag.new('...')
end