Sha256: a3536a4dbedfb87c957d05424adb07e587566dd97e4eb77d039f7f3808ce1db2

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

Contents

module NightcrawlerSwift
  class Command

    def connection
      NightcrawlerSwift.connection
    end

    def execute
      raise NotImplemented.new
    end

    protected

    def get url, params = {}
      prepare_params params
      resource = resource_for url
      resource.get(params[:headers])
    end

    def put url, params = {}
      prepare_params params
      resource = resource_for url
      resource.put(params[:body], params[:headers])
    end

    def delete url, params
      prepare_params params
      resource = resource_for url
      resource.delete(params[:headers])
    end

    private

    def resource_for url
      RestClient::Resource.new url, verify_ssl: false
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nightcrawler_swift-0.3.0 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.2.3 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.2.2 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.2.1 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.2.0 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.1.1 lib/nightcrawler_swift/command.rb
nightcrawler_swift-0.1.0 lib/nightcrawler_swift/command.rb