Sha256: b4ad0316ca6613f4fb5e0b47ea488d078b1694f44f42245439fad08f2b7bfb63

Contents?: true

Size: 568 Bytes

Versions: 1

Compression:

Stored size: 568 Bytes

Contents

module Uatu
  class Base
    include Uatu::Endpoints::Single
    include Uatu::Endpoints::Collection
    include Uatu::Endpoints::Nested

    attr_accessor :last_request_url

  private

    def request_and_build connection
      response = connection.request
      parsed_body = JSON.parse(response.body)

      @last_request_url = response.to_hash[:url].to_s

      output = parsed_body['data']['results'].map do |resource_hash|
        "Uatu::#{connection.resource.split('_').last.classify}".constantize.new(resource_hash)
      end

      output
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uatu-marvel-0.1.0 lib/uatu/base.rb