lib/jsonapionify/api/base/doc_helper.rb in jsonapionify-0.0.1.pre vs lib/jsonapionify/api/base/doc_helper.rb in jsonapionify-0.9.0
- old
+ new
@@ -1,33 +1,42 @@
module JSONAPIonify::Api
module Base::DocHelper
+ Link = Struct.new(:title, :href)
def self.extended(klass)
klass.class_eval do
extend JSONAPIonify::InheritedAttributes
inherited_array_attribute :links
end
end
- def link(href)
- links << href
+ def documentation_order(resources_in_order)
+ @documentation_order = resources_in_order
end
+ def link(title, href)
+ links << Link.new(title, href)
+ end
+
def title(title)
@title = title
end
def description(description)
@description = description
end
def documentation_output(request)
- @documentation_output ||= JSONAPIonify::Documentation.new(documentation_object(request)).result
+ #cache_store.fetch(resource_signature) do
+ JSONAPIonify::Documentation.new(documentation_object(request)).result
+ #end
end
def resources_in_order
indexes = @documentation_order || []
- resources.sort_by { |resource| indexes.index(resource.name) || indexes.length }
+ resources.sort_by(&:name).sort_by do |resource|
+ indexes.map(&:to_s).index(resource.type) || indexes.length
+ end
end
def documentation_object(request)
base_url = URI.parse(request.url).tap do |uri|
uri.query = nil