Class: WpApiClient::Entities::Term
Instance Attribute Summary
Attributes inherited from BaseEntity
#resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseEntity
#embedded, #initialize, #links
Class Method Details
.represents?(json) ⇒ Boolean
6
7
8
|
# File 'lib/wp_api_client/entities/term.rb', line 6
def self.represents?(json)
json.dig("_links", "about") and json["_links"]["about"].first["href"] =~ /wp\/v2\/taxonomies/
end
|
Instance Method Details
#id ⇒ Object
28
29
30
|
# File 'lib/wp_api_client/entities/term.rb', line 28
def id
term["id"]
end
|
#name ⇒ Object
20
21
22
|
# File 'lib/wp_api_client/entities/term.rb', line 20
def name
term["name"]
end
|
#posts(post_type = "post") ⇒ Object
14
15
16
17
18
|
# File 'lib/wp_api_client/entities/term.rb', line 14
def posts(post_type = "post")
post_type_links = links["http://api.w.org/v2/post_type"]
link = post_type_links.find { |link| link["href"] =~ /wp\/v2\/#{post_type}/ }
@api.get(link["href"]) if link
end
|
#slug ⇒ Object
24
25
26
|
# File 'lib/wp_api_client/entities/term.rb', line 24
def slug
term["slug"]
end
|
#taxonomy ⇒ Object
10
11
12
|
# File 'lib/wp_api_client/entities/term.rb', line 10
def taxonomy
@api.get(links["about"].first["href"])
end
|