lib/tickethub/collection.rb in tickethub-0.3.0 vs lib/tickethub/collection.rb in tickethub-0.3.1
- old
+ new
@@ -20,11 +20,11 @@
instance_variable_defined?("@#{type}") ? instance_variable_get("@#{type}") :
instance_variable_set("@#{type}", Tickethub::Collection.new(endpoint[type], options[:klass]))
end
end
- klass.scopes.each do |key, block|
+ klass.collection_methods.merge(klass.scopes).each do |key, block|
define_singleton_method key, &block
end
super() do |yielder|
self.reload! if cache.nil?
@@ -137,9 +137,11 @@
self.offset(search).first
when Hash
self.filter(search).first
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.load endpoint, endpoint.get(params)
else
raise ArgumentError, 'invalid search value type'
\ No newline at end of file