Sha256: 208ea3e60d72cd24e7d419bb84ad871b4705035493c1aa4675dd190e3a6cdfe5

Contents?: true

Size: 402 Bytes

Versions: 5

Compression:

Stored size: 402 Bytes

Contents

require "json"
module LucidHttp

  module Formatter

    def  self.for(keyword)
      {
        plain: PlainFormatter.new,
        json:  JsonFormatter.new,
      }.fetch(keyword)
    end

    class PlainFormatter
      def call(response_body)
        response_body
      end
    end

    class JsonFormatter
      def call(response_body)
        JSON.parse(response_body)
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lucid_http-1.2.1 lib/lucid_http/formatters.rb
lucid_http-1.2.0 lib/lucid_http/formatters.rb
lucid_http-1.1.1 lib/lucid_http/formatters.rb
lucid_http-1.1.0 lib/lucid_http/formatters.rb
lucid_http-1.0.0 lib/lucid_http/formatters.rb