Skip to content

Commit

Permalink
DynamicFinder#method_missing can handle case-insensitive calls to fin…
Browse files Browse the repository at this point in the history
…d_by or find_all_by
  • Loading branch information
shuber committed Jan 25, 2013
1 parent 0dcfa33 commit afd80bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/queryable_array/dynamic_finder.rb
Expand Up @@ -35,7 +35,7 @@ def finder?(method_name)
def method_missing(method_name, *arguments) def method_missing(method_name, *arguments)
if query = finder?(method_name) if query = finder?(method_name)
search = Hash[query[:attributes].split('_and_').zip(arguments)] search = Hash[query[:attributes].split('_and_').zip(arguments)]
send "find_#{query[:type]}", search send "find_#{query[:type].downcase}", search
else else
super super
end end
Expand Down
5 changes: 5 additions & 0 deletions test/queryable_array_test.rb
Expand Up @@ -168,6 +168,11 @@
collection.pAgE_1?.must_equal true collection.pAgE_1?.must_equal true
collection.missing?.must_equal false collection.missing?.must_equal false
end 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 end


describe :respond_to_missing? do describe :respond_to_missing? do
Expand Down

0 comments on commit afd80bc

Please sign in to comment.