Class: Coppertone::Mechanism::DomainSpecOptional
- Inherits:
-
DomainSpecMechanism
- Object
- Coppertone::Mechanism
- DomainSpecMechanism
- Coppertone::Mechanism::DomainSpecOptional
- Defined in:
- lib/coppertone/mechanism/domain_spec_optional.rb
Overview
Parent class for mechanisms that use an optional domain spec.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from DomainSpecMechanism
Attributes inherited from Coppertone::Mechanism
Class Method Summary collapse
Instance Method Summary collapse
- #generate_target_name(macro_context, request_context) ⇒ Object
- #handle_invalid_domain(_macro_context, _options) ⇒ Object
-
#initialize(attributes) ⇒ DomainSpecOptional
constructor
A new instance of DomainSpecOptional.
- #match?(macro_context, request_context) ⇒ Boolean
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) ⇒ DomainSpecOptional
Returns a new instance of DomainSpecOptional.
11 12 13 14 15 16 17 18 19 |
# File 'lib/coppertone/mechanism/domain_spec_optional.rb', line 11 def initialize(attributes) super(attributes) return if attributes.blank? raw_domain_spec = trim_domain_spec(attributes) @domain_spec = Coppertone::DomainSpec.new(raw_domain_spec) rescue Coppertone::MacroStringParsingError raise Coppertone::InvalidMechanismError end |
Class Method Details
.create(attributes) ⇒ Object
7 8 9 |
# File 'lib/coppertone/mechanism/domain_spec_optional.rb', line 7 def self.create(attributes) new(attributes) end |
Instance Method Details
#generate_target_name(macro_context, request_context) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/coppertone/mechanism/domain_spec_optional.rb', line 31 def generate_target_name(macro_context, request_context) if domain_spec target_name_from_domain_spec(macro_context, request_context) else macro_context.domain end end |
#handle_invalid_domain(_macro_context, _options) ⇒ Object
39 40 41 |
# File 'lib/coppertone/mechanism/domain_spec_optional.rb', line 39 def handle_invalid_domain(_macro_context, ) raise RecordParsingError end |
#match?(macro_context, request_context) ⇒ Boolean
21 22 23 24 25 26 27 28 29 |
# File 'lib/coppertone/mechanism/domain_spec_optional.rb', line 21 def match?(macro_context, request_context) request_context.register_dns_lookup_term target_name = generate_target_name(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 |