Sha256: 537be96995108c75f1bc6cec2b8947a6919d277e8287794db970a35662a26d32

Contents?: true

Size: 525 Bytes

Versions: 1

Compression:

Stored size: 525 Bytes

Contents

# frozen_string_literal: true

module Smartling
  module Verbs
    %i[get put post patch delete].each do |verb|
      define_method(verb) do |path, options = {}|
        authenticate do |token|
          (options[:headers] ||= {})[:Authorization] = "Bearer #{token}"
          resp = self.class.send(verb, path, options).parsed_response
          return resp unless resp.is_a?(Hash)
          hh = HipsterHash[resp]
          return hh unless hh.key?(:response)
          hh.response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartring-0.0.7 lib/smartling/verbs.rb