lib/restful_model_collection.rb in nylas-2.0.1 vs lib/restful_model_collection.rb in nylas-3.0.0

- old
+ new

@@ -1,14 +1,14 @@ require 'restful_model' -module Inbox +module Nylas class RestfulModelCollection attr_accessor :filters def initialize(model_class, api, filters = {}) - raise StandardError.new unless api.class <= Inbox::API + raise StandardError.new unless api.class <= Nylas::API @model_class = model_class @filters = filters @_api = api end @@ -28,11 +28,11 @@ end end def count RestClient.get(url, params: @filters.merge(view: 'count')) { |response,request,result| - json = Inbox.interpret_response(result, response) + json = Nylas.interpret_response(result, response) return json['count'] } end def first @@ -123,11 +123,11 @@ def get_model(id) model = nil RestClient.get("#{url}/#{id}"){ |response,request,result| - json = Inbox.interpret_response(result, response, {:expected_class => Object}) + json = Nylas.interpret_response(result, response, {:expected_class => Object}) if @model_class < RestfulModel model = @model_class.new(@_api) model.inflate(json) else model = @model_class.new(json) @@ -141,10 +141,10 @@ filters[:offset] = offset filters[:limit] = limit models = [] RestClient.get(url, :params => filters){ |response,request,result| - items = Inbox.interpret_response(result, response, {:expected_class => Array}) + items = Nylas.interpret_response(result, response, {:expected_class => Array}) models = inflate_collection(items) } models end