Sha256: 11055e47fcd6b3ea205c2ce4b7b287e40df211cb5abd72c24620025e0787a7d8
Contents?: true
Size: 593 Bytes
Versions: 44
Compression:
Stored size: 593 Bytes
Contents
prepend Respond, Actions respond.with_json class VersionedResponse def to_json(options = {}) JSON::dump(self.as_json(options)) end # Modelled after http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html def as_json(options = {}) if options[:version] == '1' {"message" => "Hello World"} elsif options[:version] == '2' {"message" => "Goodbye World"} else {} end end end # To get different verions of the response, use: # Accept: application/json;version=1 # Accept: application/json;version=2 on 'fetch' do succeed! content: VersionedResponse.new end
Version data entries
44 entries across 44 versions & 1 rubygems