Sha256: 48f393d1de8353e04ebab7dda0a30fe8392830449bdf6ff6bffb506e49467b57

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module NightcrawlerSwift
  class Command

    def connection
      NightcrawlerSwift.connection.tap do |conn|
        conn.connect! unless conn.connected?
      end
    end

    def options
      NightcrawlerSwift.options
    end

    # :nocov:
    def execute
      raise NotImplemented.new
    end
    # :nocov:

    protected

    def get url, params = {}
      prepare_params params
      Gateway.new(url).request {|r| r.get params[:headers]}
    end

    def put url, params = {}
      prepare_params params
      Gateway.new(url).request {|r| r.put params[:body], params[:headers]}
    end

    def delete url, params
      prepare_params params
      Gateway.new(url).request {|r| r.delete params[:headers]}
    end

    private

    def prepare_params params
      params[:headers] ||= {}
      params[:headers]["X-Storage-Token"] = connection.token_id
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nightcrawler_swift-0.5.0 lib/nightcrawler_swift/command.rb