Permalink
Browse files

DynamicFinder#method_missing can handle case-insensitive calls to fin…

…d_by or find_all_by
  • Loading branch information...
1 parent 0dcfa33 commit afd80bc69d6cb8e6f7c9c4626cb50f27f9769564 @shuber committed Jan 25, 2013
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/queryable_array/dynamic_finder.rb
  2. +5 −0 test/queryable_array_test.rb
@@ -35,7 +35,7 @@ def finder?(method_name)
def method_missing(method_name, *arguments)
if query = finder?(method_name)
search = Hash[query[:attributes].split('_and_').zip(arguments)]
- send "find_#{query[:type]}", search
+ send "find_#{query[:type].downcase}", search
else
super
end
@@ -168,6 +168,11 @@
collection.pAgE_1?.must_equal true
collection.missing?.must_equal false
end
+
+ it 'should be case insensitive' do
+ collection.fInD_By_name('PAGE_1').must_equal pages[0]
+ collection.fInD_ALL_By_name('PAGE_1').must_equal [pages[0]]
+ end
end
describe :respond_to_missing? do

0 comments on commit afd80bc

Please sign in to comment.