Class: WpApiClient::Entities::Term
- Inherits:
-
Base
- Object
- Base
- WpApiClient::Entities::Term
show all
- Defined in:
- lib/wp_api_client/entities/term.rb
Instance Attribute Summary
Attributes inherited from Base
#resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
build, #initialize, #links, #relations
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
26
27
28
|
# File 'lib/wp_api_client/entities/term.rb', line 26
def id
term["id"]
end
|
#name ⇒ Object
18
19
20
|
# File 'lib/wp_api_client/entities/term.rb', line 18
def name
term["name"]
end
|
#posts(post_type = nil) ⇒ Object
14
15
16
|
# File 'lib/wp_api_client/entities/term.rb', line 14
def posts(post_type = nil)
relations("http://api.w.org/v2/post_type", post_type)
end
|
#slug ⇒ Object
22
23
24
|
# File 'lib/wp_api_client/entities/term.rb', line 22
def slug
term["slug"]
end
|
#taxonomy ⇒ Object
10
11
12
|
# File 'lib/wp_api_client/entities/term.rb', line 10
def taxonomy
WpApiClient.get_client.get(links["about"].first["href"])
end
|