module Draper::Finders
Provides automatically-decorated finder methods for your decorators. You do not have to extend this module directly; it is extended by {Decorator.decorates_finders}.
Public Instance Methods
all(options = {})
click to toggle source
# File lib/draper/finders.rb, line 10 def all(options = {}) decorate_collection(object_class.all, options) end
find(id, options = {})
click to toggle source
# File lib/draper/finders.rb, line 6 def find(id, options = {}) decorate(object_class.find(id), options) end
first(options = {})
click to toggle source
# File lib/draper/finders.rb, line 14 def first(options = {}) decorate(object_class.first, options) end
last(options = {})
click to toggle source
# File lib/draper/finders.rb, line 18 def last(options = {}) decorate(object_class.last, options) end
method_missing(method, *args, &block)
click to toggle source
Decorates dynamic finder methods (`find_all_by_` and friends).
Calls superclass method
# File lib/draper/finders.rb, line 23 def method_missing(method, *args, &block) return super unless method =~ /^find_(all_|last_|or_(initialize_|create_))?by_/ result = object_class.send(method, *args, &block) options = args.extract_options! if method =~ /^find_all/ decorate_collection(result, options) else decorate(result, options) end end