Class: Coppertone::Modifier::Base
- Inherits:
-
Coppertone::Modifier
- Object
- Coppertone::Modifier
- Coppertone::Modifier::Base
- Defined in:
- lib/coppertone/modifier/base.rb
Overview
Base class including logic common to modifiers
Constant Summary
Constants inherited from Coppertone::Modifier
Instance Attribute Summary collapse
-
#domain_spec ⇒ Object
readonly
Returns the value of attribute domain_spec.
Attributes inherited from Coppertone::Modifier
Instance Method Summary collapse
- #==(other) ⇒ Object
- #context_dependent? ⇒ Boolean
- #includes_ptr? ⇒ Boolean
-
#initialize(attributes) ⇒ Base
constructor
A new instance of Base.
- #target_name_from_domain_spec(macro_context, request_context) ⇒ Object
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_spec ⇒ Object (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
22 23 24 |
# File 'lib/coppertone/modifier/base.rb', line 22 def context_dependent? domain_spec.context_dependent? end |
#includes_ptr? ⇒ 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.(macro_context, request_context) end Coppertone::Utils::DomainUtils.(domain) end |