Class: WpRpc::Collection::Categories
- Inherits:
-
Base
- Object
- Base
- WpRpc::Collection::Categories
show all
- Includes:
- Enumerable
- Defined in:
- lib/wp_rpc/collections/categories.rb
Instance Method Summary
collapse
Methods inherited from Base
#change_attributes, #conn, #pattern
Constructor Details
#initialize(*args) ⇒ Categories
Returns a new instance of Categories.
6
7
8
|
# File 'lib/wp_rpc/collections/categories.rb', line 6
def initialize(*args)
super(*args)
end
|
Instance Method Details
#[](i) ⇒ Object
23
24
25
|
# File 'lib/wp_rpc/collections/categories.rb', line 23
def [](i)
all[i]
end
|
#all ⇒ Object
10
11
12
|
# File 'lib/wp_rpc/collections/categories.rb', line 10
def all
@categories ||= load
end
|
#create(attributes) ⇒ Object
31
32
33
34
35
|
# File 'lib/wp_rpc/collections/categories.rb', line 31
def create(attributes)
new_cat = WpRpc::Category.new(attributes, :conn => conn)
new_cat.save
new_cat
end
|
#each ⇒ Object
27
28
29
|
# File 'lib/wp_rpc/collections/categories.rb', line 27
def each
all.each { |c| yield c }
end
|
#load ⇒ Object
retrieve the categories via xmlrpc
15
16
17
18
19
20
21
|
# File 'lib/wp_rpc/collections/categories.rb', line 15
def load
cats = []
conn.call('wp.getCategories', conn.blog_id, conn.username, conn.password).each do |c|
cats << WpRpc::Category.new_from_xmlrpc(c, :conn => conn)
end
@categories = cats
end
|