Created
December 16, 2012 20:54
-
-
Save svs/4312838 to your computer and use it in GitHub Desktop.
QuotationsIndexParams
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 QuotationsIndexParams | |
include Virtus | |
include DataMapper::Validations | |
attribute :scope, String, :default => 'pending' | |
attribute :sort, String, :default => 'poolability' | |
attribute :quotation, Hash, :default => {} | |
attribute :date, Date | |
validates_within :scope, :set => [nil,'all','pending','to_call','to_pool', 'cabbed'] | |
def check_scope | |
self.sort = :id if self.scope == "cabbed" | |
end | |
def valid? | |
check_scope | |
super | |
end | |
def scope_params | |
date ? {:date => date} : {} | |
end | |
def search_params | |
quotation | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment