lib/ruby-box/folder.rb in ruby-box-1.0.0 vs lib/ruby-box/folder.rb in ruby-box-1.0.1
- old
+ new
@@ -1,36 +1,20 @@
module RubyBox
class Folder < Item
- def items(item_limit=100, offset=0)
- Enumerator.new do |yielder|
- while true
- url = "#{RubyBox::API_URL}/#{resource_name}/#{id}/items?limit=#{item_limit}&offset=#{offset}"
- resp = @session.get( url )
- resp['entries'].each do |entry|
- yielder.yield(RubyBox::Item.factory(@session, entry))
- end
- offset += resp['entries'].count
- break if resp['offset'].to_i + resp['limit'].to_i >= resp['total_count'].to_i
- end
- end
- end
+ has_many :discussions
+ has_many_paginated :items
+
def files(name=nil, item_limit=100, offset=0)
items(item_limit, offset).select do |item|
item.kind_of? RubyBox::File and (name.nil? or item.name == name)
end
end
def folders(name=nil, item_limit=100, offset=0)
items(item_limit, offset).select do |item|
item.kind_of? RubyBox::Folder and (name.nil? or item.name == name)
end
- end
-
- def discussions
- url = "#{RubyBox::API_URL}/#{resource_name}/#{id}/discussions"
- resp = @session.get( url )
- resp['entries'].map {|i| Discussion.new(@session, i)}
end
def upload_file(filename, data)
file = RubyBox::File.new(@session, {
'name' => filename,
\ No newline at end of file