lib/petit/app.rb
# Returns a formatted representation of a given shortcode object
# @param shortcode [Shortcode] the shortcode object to format
# @return [String] a JSON representation of the object if the ACCEPT header requests JSON
#  otherwise a plain-text representation of the object
Returns a formatted representation of a given shortcode object
Returns a formatted representation of a given shortcode object
def return_shortcode(shortcode)
      if request.accept?('application/json') || request.accept?('application/vnd.api+json')
        response.headers['Content-Type'] = 'application/vnd.api+json'
        JSONAPI::Serializer.serialize(shortcode).to_json
      else
        shortcode.name + ' (' + shortcode.destination + ') '
      end
    end
def return_shortcode ( shortcode ) if request . accept? ( 'application/json' ) || request . accept? ( 'application/vnd.api+json' ) response . headers [ 'Content-Type' ] = 'application/vnd.api+json' JSONAPI :: Serializer . serialize ( shortcode ) . to_json else shortcode . name + ' (' + shortcode . destination + ') ' end end
Returns a formatted representation of a given shortcode object
Returns a formatted representation of a given shortcode object
a JSON representation of the object if the ACCEPT header requests JSON otherwise a plain-text representation of the object
a JSON representation of the object if the ACCEPT header requests JSON otherwise a plain - text representation of the object
String
shortcode
the shortcode object to format
the shortcode object to format