Last active
June 9, 2021 17:52
-
-
Save RobDoan/8f7a5b80da0e75e063deec1c7c83a481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TemplateProcessor | |
attribute_reader :vendor_templates | |
def initialize(templates) | |
@vendor_template = templates | |
end | |
def process(code) | |
vendor_templates.reduce(code) do |result, vendor_template| | |
vendor_template.process(code) | |
end | |
end | |
# vendor_template_id issues | |
# one domain | |
def domain | |
@vendor_template.map(&:domain).first | |
end | |
# or join multi domain ??? | |
def domain | |
@vendor_template.map(&:domain).join(',') | |
end | |
end | |
### Modify vendor detect: | |
def detect(code) | |
candidates = @domains.values.select { |t| t.domain_matches?(code_or_url) } | |
substitutable = candidates.select { |t| t.would_substitute?(code_or_url) } | |
TemplateProcessor.new(substitutable) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment