Sha256: 828938bb9d9828cadd1bb655ee16d1bfb29661c536e24bad069a80a7f443756a

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

Contents

require 'xftp/dsl/block_evaluator'

module XFTP
  module Session
    # @abstract Base class for xftp session adapters
    # @api private
    class Base
      include DSL::BlockEvaluator

      attr_reader :uri, :credentials, :settings

      # Creates a session adapter instance
      # @param [URI] uri the remote uri
      # @param [Hash] settings the adapter connection settings
      def initialize(uri, settings = {})
        @uri = uri
        @credentials = settings.delete(:credentials) || {}
        @settings = settings
      end

      # Opens a new connection, evaluates the given block and closes the connection
      # @param [Proc] callback the callback to operate on a connection session
      def start(&callback)
        open
        evaluate(&callback)
        close
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xftp-0.2.1.pre.alpha lib/xftp/session/base.rb
xftp-0.2.0.pre.alpha lib/xftp/session/base.rb
xftp-0.1.0.pre.alpha lib/xftp/session/base.rb