Class: Coppertone::Modifier::Base

Inherits:
Coppertone::Modifier show all
Defined in:
lib/coppertone/modifier/base.rb

Overview

Base class including logic common to modifiers

Direct Known Subclasses

Exp, Redirect

Constant Summary

Constants inherited from Coppertone::Modifier

MODIFIER_REGEXP

Instance Attribute Summary collapse

Attributes inherited from Coppertone::Modifier

#arguments

Instance Method Summary collapse

Methods inherited from Coppertone::Modifier

build, build_unknown, class_builder, #label, matching_term, register, #to_s

Constructor Details

#initialize(attributes) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/coppertone/modifier/base.rb', line 6

def initialize(attributes)
  super(attributes)
  raise InvalidModifierError if attributes.blank?
  @domain_spec = Coppertone::DomainSpec.new(attributes)
rescue Coppertone::MacroStringParsingError
  raise Coppertone::InvalidModifierError
end

Instance Attribute Details

#domain_specObject (readonly)

Returns the value of attribute domain_spec.



5
6
7
# File 'lib/coppertone/modifier/base.rb', line 5

def domain_spec
  @domain_spec
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
# File 'lib/coppertone/modifier/base.rb', line 30

def ==(other)
  return false unless other.instance_of? self.class
  domain_spec == other.domain_spec
end

#context_dependent?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/coppertone/modifier/base.rb', line 22

def context_dependent?
  domain_spec.context_dependent?
end

#includes_ptr?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/coppertone/modifier/base.rb', line 26

def includes_ptr?
  domain_spec.includes_ptr?
end

#target_name_from_domain_spec(macro_context, request_context) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/coppertone/modifier/base.rb', line 14

def target_name_from_domain_spec(macro_context, request_context)
  if domain_spec
    domain =
      domain_spec.expand(macro_context, request_context)
  end
  Coppertone::Utils::DomainUtils.macro_expanded_domain(domain)
end