lib/useless/doc/serialization/dump.rb in useless-doc-0.2.0 vs lib/useless/doc/serialization/dump.rb in useless-doc-0.2.1

- old
+ new

@@ -16,12 +16,27 @@ # def self.hash_to_json(hash) hash.is_a?(String) ? hash : Oj.dump(hash) end - # Converts +Doc::Resource+ instance to a JSON representation. + # Converts +Core::API+ instance to a JSON representation. # - # @param [Doc::Resource] resource the resource to be converted to JSON. + # @param [Core::API] api the API to be converted to JSON. + # + # @return [String] a JSON representation of the specified API. + # + def self.api(api) + if api + hash_to_json \ + 'url' => api.url, + 'description' => api.description, + 'resources' => api.resources.map { |resource| resource(resource) } + end + end + + # Converts a +Core::Resource+ instance to a JSON representation. + # + # @param [Core::Resource] resource the resource to be converted to JSON. # # @return [String] a JSON representation of the specified resource. # def self.resource(resource) if resource