Class: Coppertone::Mechanism::DomainSpecRequired

Inherits:
DomainSpecMechanism show all
Defined in:
lib/coppertone/mechanism/domain_spec_required.rb

Overview

Parent class for mechanisms that use a required.

Direct Known Subclasses

Exists, Include

Instance Attribute Summary

Attributes inherited from DomainSpecMechanism

#domain_spec

Attributes inherited from Coppertone::Mechanism

#arguments

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DomainSpecMechanism

#==, #context_dependent?, dns_lookup_term?, #hash, #includes_ptr?, #target_domain, #target_name_from_domain_spec, #trim_domain_spec

Methods inherited from Coppertone::Mechanism

build, class_builder, #context_dependent?, dns_lookup_term?, #dns_lookup_term?, #includes_ptr?, register, #to_s

Constructor Details

#initialize(attributes) ⇒ DomainSpecRequired

Returns a new instance of DomainSpecRequired.



9
10
11
12
13
14
15
16
17
# File 'lib/coppertone/mechanism/domain_spec_required.rb', line 9

def initialize(attributes)
  super(attributes)
  raw_domain_spec = trim_domain_spec(attributes)
  raise InvalidMechanismError if raw_domain_spec.blank?

  @domain_spec = Coppertone::DomainSpec.new(raw_domain_spec)
rescue Coppertone::MacroStringParsingError
  raise Coppertone::InvalidMechanismError
end

Class Method Details

.create(attributes) ⇒ Object



5
6
7
# File 'lib/coppertone/mechanism/domain_spec_required.rb', line 5

def self.create(attributes)
  new(attributes)
end

Instance Method Details

#handle_invalid_domain(_macro_context, _options) ⇒ Object

Raises:



30
31
32
# File 'lib/coppertone/mechanism/domain_spec_required.rb', line 30

def handle_invalid_domain(_macro_context, _options)
  raise RecordParsingError
end

#match?(macro_context, request_context) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
# File 'lib/coppertone/mechanism/domain_spec_required.rb', line 19

def match?(macro_context, request_context)
  request_context.register_dns_lookup_term
  target_name =
    target_name_from_domain_spec(macro_context, request_context)
  if target_name
    match_target_name(macro_context, request_context, target_name)
  else
    handle_invalid_domain(macro_context, request_context)
  end
end