lib/namespace.rb in inbox-0.15.0 vs lib/namespace.rb in inbox-0.15.1
- old
+ new
@@ -59,44 +59,41 @@
@events ||= RestfulModelCollection.new(Event, @_api, @id)
end
def get_cursor(timestamp)
# Get the cursor corresponding to a specific timestamp.
- path = @_api.url_for_path("n/#{@namespace_id}/delta/generate_cursor")
+ path = @_api.url_for_path("/n/#{@namespace_id}/delta/generate_cursor")
data = { :start => timestamp }
cursor = nil
RestClient.post(path, data.to_json, :content_type => :json) do |response,request,result|
json = Inbox.interpret_response(result, response, {:expected_class => Object})
cursor = json["cursor"]
end
- return cursor
+ cursor
end
OBJECTS_TABLE = {
"account" => Inbox::Account,
"calendar" => Inbox::Calendar,
"draft" => Inbox::Draft,
"thread" => Inbox::Thread,
- "account" => Inbox::Account,
- "calendar" => Inbox::Calendar,
"contact" => Inbox::Contact,
- "draft" => Inbox::Draft,
"event" => Inbox::Event,
"file" => Inbox::File,
"message" => Inbox::Message,
"namespace" => Inbox::Namespace,
"tag" => Inbox::Tag,
- "thread" => Inbox::Thread
}
def deltas(cursor, exclude_types=[])
+ raise 'Please provide a block for receiving the delta objects' if !block_given?
exclude_string = ""
- if not exclude_types.empty?
+ if exclude_types.any?
exclude_string = "&exclude_types="
exclude_types.each do |value|
count = 0
if OBJECTS_TABLE.has_value?(value)
@@ -108,10 +105,10 @@
exclude_string = exclude_string[0..-2]
# loop and yield deltas until we've come to the end.
loop do
- path = @_api.url_for_path("n/#{@namespace_id}/delta?cursor=#{cursor}#{exclude_string}")
+ path = @_api.url_for_path("/n/#{@namespace_id}/delta?cursor=#{cursor}#{exclude_string}")
json = nil
RestClient.get(path) do |response,request,result|
json = Inbox.interpret_response(result, response, {:expected_class => Object})
end