Sha256: 82c0a3a4787b7c79781dcf03a1450ed106730e533d973c0e2c3704418bc93db9

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

require "news_stand/version"
require "news_stand/validator"

module NewsStand
  def self.register(service, adapter)
    raise InvalidAdapter unless is_valid_adapter?(adapter)
    adapters[service] = adapter
  end

  def self.is_valid_adapter?(adapter)
    Validator.new(adapter).valid?
  end

  def self.adapter_for(service)
    raise UnknownAdapter unless adapters.keys.include?(service)
    adapters[service]
  end

  def self.adapters
    @adapters ||= {}
  end

  def self.reset
    @adapters = {}
  end

  class UnknownAdapter < StandardError ; end
  class InvalidAdapter < StandardError ; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
news_stand-0.1.1 lib/news_stand.rb