Sha256: 9ffe71d91058573330c61629ec6a4bb90548b6e7ee649798da4bd381b7859d1d

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

module Yodeler
  class Endpoint
    attr_reader :name
    attr_reader :adapter

    def initialize(name)
      @name = name
      yield(self) if block_given?
    end

    # Set the adapter this endpoint will use
    #
    # @example
    #   endpoint = Yodeler::Endpoint.new(:dashboard)
    #   endpoint.use(:http)
    #
    # @example
    #   endpoint = Yodeler::Endpoint.new(:dashboard)
    #   endpoint.use(:http) do |http|
    #     #your adapter setup here
    #   end
    #
    # @param [Symbol] name the registered name of the adapter
    # @return [~Yodeler::Adapters::Base] yodeler adapter
    def use(name)
      @adapter = Yodeler.registered_adapters(name).new
      yield(@adapter) if block_given?
      @adapter
    end

    def adapter
      @adapter
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yodeler-0.1.1 lib/yodeler/endpoint.rb