Sha256: 1d03adf57aa35d21e613eb5dcb7f77e7246cde86029f680bf25ae39310bdd9f0
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module WP::API module Endpoints def posts(query = {}) resources('posts', query) end def post(id, query = {}) resource('posts', id, query) end def post_named(slug) resource_named('posts', slug) end def post_meta(id, query = {}) resource_subpath('posts', id, 'meta', query).first end def pages(query = {}) resources('pages', query) end def page(id, query = {}) resource('pages', id, query) end def page_named(slug) resource_named('pages', slug) end private def resources(res, query = {}) resources, headers = get(res, query) resources.collect do |hash| resource_class(res).new(hash, headers) end end def resource(res, id, query = {}) resource_class(res).new *get("#{res}/#{id}", query) end def resource_subpath(res, id, subpath, query = {}) get("#{res}/#{id}/#{subpath}", query).first end def resource_named(res, slug) resources(res, name: slug).first end def resource_class(res) WP::API::const_get(res.classify) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wp-api-0.1.3 | lib/wp/api/endpoints.rb |