Sha256: abb8b644f0a86fc00d62282fd9df8ca9d76452666c7ed006fb827c6af66ce14b

Contents?: true

Size: 490 Bytes

Versions: 2

Compression:

Stored size: 490 Bytes

Contents

require 'multi_json'

module Rakuna
  module Content
    # Mixin to add JSON support to resources
    module JSON
      def content_types_provided
        [['application/json', :to_json]]
      end

      def content_types_accepted
        [['application/json', :from_json]]
      end

      def from_json
        input
      end

      def payload
        @payload ||= MultiJson.load request.body.to_s
      end

      def to_json
        MultiJson.dump output
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rakuna-0.1.1 lib/rakuna/content/json.rb
rakuna-0.1.0 lib/rakuna/content/json.rb