lib/wp/api/endpoints.rb in wp-api-0.0.2 vs lib/wp/api/endpoints.rb in wp-api-0.0.3

- old
+ new

@@ -1,16 +1,20 @@ module WP::API module Endpoints def posts(query = {}) - get("posts", query).collect do |hash| - Post.new(hash) + posts, headers = get("posts", query) + posts.collect do |hash| + WP::API::Post.new(hash, headers) end end def post(id, query = {}) - hash = get("posts/#{id}", query) - Post.new(hash) + WP::API::Post.new *get("posts/#{id}", query) + end + + def post_named(slug) + WP::API::Post.new *get("posts", name: slug).first end end end