lib/tickethub/collection.rb in tickethub-0.0.6 vs lib/tickethub/collection.rb in tickethub-0.0.7
- old
+ new
@@ -44,10 +44,14 @@
response.status == 206 ?
response.headers.values_at(*%w(x-total-count x-offset x-limit))
.collect { |value| value[0].to_i } : [@cache.length, 0, @cache.length]
end
+ def last
+ offset(count - 1).first
+ end
+
def limit(value = nil)
if value.nil?
reload! if @limit.nil?
return @limit
else
@@ -128,10 +132,10 @@
self.filter(key).first
when Range
self.offset(key.min).first(key.max)
when String
options = { params: args[1] || {} }.merge args[2] || {}
- @klass.load(@endpoint[nil, options], 'id' => key).reload!
+ @klass.load @klass.endpoint[key, @endpoint[nil, options].options]
else
raise ArgumentError, 'invalid search value type'
end
end
\ No newline at end of file