Class: Coppertone::Mechanism::IncludeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/coppertone/mechanism/include_matcher.rb

Overview

Implements the include mechanism.

Defined Under Namespace

Classes: IncludeRecordEvaluator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ IncludeMatcher

Returns a new instance of IncludeMatcher.



23
24
25
# File 'lib/coppertone/mechanism/include_matcher.rb', line 23

def initialize(record)
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



21
22
23
# File 'lib/coppertone/mechanism/include_matcher.rb', line 21

def record
  @record
end

Instance Method Details

#match?(macro_context, request_context) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



27
28
29
30
31
32
33
34
# File 'lib/coppertone/mechanism/include_matcher.rb', line 27

def match?(macro_context, request_context)
  raise Coppertone::NoneIncludeResultError if record.nil?

  record_result =
    IncludeRecordEvaluator.new(record)
                          .evaluate(macro_context, request_context)
  record_result.pass?
end