Skip to content

Instantly share code, notes, and snippets.

@RobDoan
Last active June 9, 2021 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobDoan/8f7a5b80da0e75e063deec1c7c83a481 to your computer and use it in GitHub Desktop.
Save RobDoan/8f7a5b80da0e75e063deec1c7c83a481 to your computer and use it in GitHub Desktop.
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