2022-03-04 22:26:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ActiveStorage
|
2022-03-05 23:08:55 +00:00
|
|
|
class Service
|
2022-03-04 22:26:56 +00:00
|
|
|
# Modificaciones a ActiveStorage::Service::Registry
|
|
|
|
module RegistryDecorator
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
# El mismo comportamiento que #fetch con el agregado de generar
|
|
|
|
# un {JekyllService} para cada sitio.
|
|
|
|
def fetch(name)
|
|
|
|
services.fetch(name.to_sym) do |key|
|
|
|
|
if configurations.include?(key)
|
|
|
|
services[key] = configurator.build(key)
|
|
|
|
elsif (site = Site.find_by_name(key))
|
2022-03-05 23:09:09 +00:00
|
|
|
services[key] = ActiveStorage::Service::JekyllService.build_for_site(site: site)
|
2022-03-04 22:26:56 +00:00
|
|
|
elsif block_given?
|
|
|
|
yield key
|
|
|
|
else
|
|
|
|
raise KeyError, "Missing configuration for the #{key} Active Storage service. " \
|
|
|
|
"Configurations available for the #{configurations.keys.to_sentence} services."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActiveStorage::Service::Registry.include ActiveStorage::Service::RegistryDecorator
|