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.



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

def initialize(record)
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



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

def record
  @record
end

Instance Method Details

#match?(macro_context, request_context) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



25
26
27
28
29
30
31
# File 'lib/coppertone/mechanism/include_matcher.rb', line 25

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