lib/tickethub/collection.rb in tickethub-0.3.30 vs lib/tickethub/collection.rb in tickethub-0.3.31

- old
+ new

@@ -8,12 +8,13 @@ DEFAULT_OFFSET = 0.freeze attr_accessor :cache attr_reader :count, :endpoint, :params - def initialize(endpoint, klass, params = {}) + def initialize(endpoint, klass, params = {}, options = {}) @params = params.dup + @options = options.dup @endpoint = endpoint @klass = klass klass.registered_types.each do |type, options| define_singleton_method type do @@ -140,19 +141,18 @@ when Range self.offset(search.min).first(search.max) when Array self.filter(id: search) when String - endpoint = self.endpoint[@klass.path, CGI::escape(search)] - @klass.call endpoint, endpoint.get(params) + @klass.call endpoint, CGI::escape(search), @options else raise ArgumentError, 'invalid search value type' end end def create(attributes = {}) - @klass.call endpoint, post(attributes) + @klass.call endpoint, post(attributes), @options rescue Tickethub::ResourceInvalid => err - @klass.call endpoint, Tickethub::Response.new(err.response).decoded + @klass.call endpoint, Tickethub::Response.new(err.response).decoded, @options end end end \ No newline at end of file