Class: WpRpc::Collection::Posts

Inherits:
Base
  • Object
show all
Defined in:
lib/wp_rpc/collections/posts.rb

Instance Method Summary collapse

Methods inherited from Base

#change_attributes, #conn, #initialize, #pattern

Constructor Details

This class inherits a constructor from WpRpc::Base

Instance Method Details

#allObject



25
26
27
# File 'lib/wp_rpc/collections/posts.rb', line 25

def all
  change_attributes(conn.call('wp.getPosts', conn.blog_id, conn.username, conn.password), pattern)
end

#find(qid, options = { }) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/wp_rpc/collections/posts.rb', line 10

def find(qid, options = { })
  if qid.is_a?(Array)
    qid.collect { |sqid| find(sqid) }
  elsif qid == :recent
    find_recent(options)
  else
    post = conn.get_post(qid)
    Post.new(post, :conn => conn)
  end
end

#find_recent(options = { }) ⇒ Object



4
5
6
7
8
# File 'lib/wp_rpc/collections/posts.rb', line 4

def find_recent(options = { })
  options = { :limit => 10 }.merge(options)
  posts = conn.get_recent_posts(options[:limit])
  posts.collect { |post|  Post.new(post, :conn => conn) }
end

#new(attributes = { }) ⇒ Object



21
22
23
# File 'lib/wp_rpc/collections/posts.rb', line 21

def new(attributes = { })
  WpRpc::Post.new(attributes, :conn => conn)
end