eBooru/app/logical/sources/strategies.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

17 lines
329 B
Ruby

# frozen_string_literal: true
module Sources
module Strategies
def self.all
[
Strategies::PixivSlim
]
end
def self.find(url, default: Strategies::Null)
strategy = all.map { |strategy_class| strategy_class.new(url) }.detect(&:match?)
strategy || default&.new(url)
end
end
end