Sha256: b0c59bb6eb44c6458d8b6708334e7d49c6c848ddc67eab696c9fc9202363a607
Contents?: true
Size: 486 Bytes
Versions: 1
Compression:
Stored size: 486 Bytes
Contents
require 'json' require 'hashie' module HN module Request def get(path, options = {}) request(:get, path, options) end private def request(method, path, options) response = connection.send(method) do |request| request.url(path, options) end prepare(response) end def prepare(response) result = JSON.parse(response.body) rescue response.body result.is_a?(Hash) ? Hashie::Mash.new(result) : result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hn_api-0.0.2 | lib/hn/request.rb |