Sha256: 1aa7d415e68944e71eb6f56fc98444dd533daa079e5c85d83f86c8e6a3f01863

Contents?: true

Size: 461 Bytes

Versions: 6

Compression:

Stored size: 461 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)
          HipsterHash[resp].response
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smartring-0.0.6 lib/smartling/verbs.rb
smartring-0.0.5 lib/smartling/verbs.rb
smartring-0.0.4 lib/smartling/verbs.rb
smartring-0.0.3 lib/smartling/verbs.rb
smartring-0.0.2 lib/smartling/verbs.rb
smartring-0.0.1 lib/smartling/verbs.rb