Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created June 4, 2013 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsnyder/5702726 to your computer and use it in GitHub Desktop.
Save mattsnyder/5702726 to your computer and use it in GitHub Desktop.
AR like dynamic finders for Ripple #riak
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