Created
June 4, 2013 00:40
-
-
Save mattsnyder/5702726 to your computer and use it in GitHub Desktop.
AR like dynamic finders for Ripple #riak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ripple | |
module Document | |
module DynamicFinders | |
class << self | |
def included(base) | |
base.module_eval do | |
extend DynamicFindersClassMethods | |
end | |
end | |
end | |
module DynamicFindersClassMethods | |
def method_missing(method, *arguments, &block) | |
if (method.to_s.starts_with?('find_by_')) | |
find_by_index(method.to_s.gsub('find_by_','').to_sym, *arguments) | |
else | |
super | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment