Sha256: 9c3a2b75fe0febae9032978b314aa3914567957482cd51aa736ae6f17352092a

Contents?: true

Size: 463 Bytes

Versions: 9

Compression:

Stored size: 463 Bytes

Contents

require 'json'
require 'recursive_open_struct'
require 'frenetic/hal_json/response_wrapper'

class Frenetic

  class HalJson < Faraday::Middleware
    def call( environment )
      @app.call(environment).on_complete { |env| on_complete(env) }
    end

    def on_complete( env )
      if success? env
        env[:body] = ResponseWrapper.new( JSON.parse(env[:body]) )
      end
    end

    def success?( env )
      (200..201) === env[:status]
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
frenetic-0.0.12 lib/frenetic/hal_json.rb
frenetic-0.0.11 lib/frenetic/hal_json.rb
frenetic-0.0.10 lib/frenetic/hal_json.rb
frenetic-0.0.9 lib/frenetic/hal_json.rb
frenetic-0.0.8 lib/frenetic/hal_json.rb
frenetic-0.0.7 lib/frenetic/hal_json.rb
frenetic-0.0.6 lib/frenetic/hal_json.rb
frenetic-0.0.5 lib/frenetic/hal_json.rb
frenetic-0.0.4 lib/frenetic/hal_json.rb