Sha256: 9c3fbbbc7e8c0327c7975e34f4affe2a2daadc3b36b98b68a83a6ad8f4bd04be

Contents?: true

Size: 925 Bytes

Versions: 3

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require 'wcc'

require 'wcc/blogs/utils'

require 'wcc/blogs/client'
require 'wcc/blogs/errors'

require 'wcc/blogs/metadata'
require 'wcc/blogs/post'

module WCC::Blogs
  class << self
    def configure
      yield config

      @client = WCC::Blogs::Client.new(config: config)

      config
    end

    def client
      @client || raise(WCC::Blogs::NotConfiguredException, 'Not configured')
    end

    def config
      Config.instance
    end
  end

  class Config
    include Singleton

    attr_accessor :publishing_target
    attr_writer :base_url, :cache, :query_url

    def base_url
      @base_url || 'https://wcc-papyrus.herokuapp.com'
    end

    def cache
      @cache || NilCache.new
    end

    def query_url
      @query_url || 'https://papyrus.wcc/graphql'
    end

    class NilCache
      def clear; end

      def fetch(*_args)
        yield
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wcc-blogs-client-0.3.2 lib/wcc/blogs.rb
wcc-blogs-client-0.3.1 lib/wcc/blogs.rb
wcc-blogs-client-0.3.0 lib/wcc/blogs.rb