Sha256: 47410f94c31d15c1228fcf26334f60fba4630acd487dfacd9510fe8e7d04adb8

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 Bytes

Contents

module Copy
  module Request
    class Base
      attr_reader :info
      attr_accessor :response

      def initialize(info)
        @info = info
      end

      def perform
        raise Copy::AuthenticationError unless valid?
        connection.set_request_data
        send_request

        validator.validated_data_for(response)
      end

      def valid?
        return false unless info
        return false unless info.session
        return false unless info.session.valid?
        true
      end

      protected

      def send_request
        self.response = connection.request
      end

      def connection
        @connection ||= Connection.new(info)
      end

      def validator
        @validator ||= Validator.new(info)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
copy-ruby-0.0.2 lib/copy/request/base.rb
copy-ruby-0.0.1 lib/copy/request/base.rb