Created
June 27, 2012 17:28
-
-
Save factore/3005563 to your computer and use it in GitHub Desktop.
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
class DocumentFilter | |
def self.find(klass, options = {}) | |
document_filter = self.new(klass, options) | |
document_filter.results | |
end | |
def initialize(klass, options = {}) | |
@document_class = klass.to_s.capitalize.constantize | |
@options = options.symbolize_keys! | |
@documents = @document_class.where("1 = 1") | |
end | |
def results | |
@documents = @documents.send(@options[:estimate_type]) if @options[:estimate_type] | |
if @options[:aasm_current_state] | |
@documents = @documents.where(:aasm_current_state => @options[:aasm_current_state]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment