Sha256: caaa3a54b338c8f0471719e68968b319b8bc6105964c37f199b9307265a3cc35

Contents?: true

Size: 611 Bytes

Versions: 7

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

require_dependency 'scribo/application_service'

module Scribo
  class SiteFindService < ApplicationService
    attr_reader :options

    def initialize(options = {})
      super()
      @options = options
    end

    def perform
      return options[:site] if options[:site].is_a?(Scribo::Site)

      scribable = Scribo.config.scribable_for_request(options[:request])
      return nil unless scribable

      scope = scribable.sites
      scope = scope.for_host(options[:host])
      scope = scope.for_path(options[:path]) if options[:path]
      scope.first
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scribo-1.0.44 app/services/scribo/site_find_service.rb
scribo-1.0.43 app/services/scribo/site_find_service.rb
scribo-1.0.42 app/services/scribo/site_find_service.rb
scribo-1.0.41 app/services/scribo/site_find_service.rb
scribo-1.0.40 app/services/scribo/site_find_service.rb
scribo-1.0.39 app/services/scribo/site_find_service.rb
scribo-1.0.38 app/services/scribo/site_find_service.rb