Sha256: 6af83fc49b7038b7f6bb7f69ae45d7822c23628c949778c64ca255dc46e489c8

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 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

    attr_reader :adapter
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yodeler-0.1.3 lib/yodeler/endpoint.rb
yodeler-0.1.2 lib/yodeler/endpoint.rb