Skip to content

Instantly share code, notes, and snippets.

@svs
Created December 16, 2012 20:54
Show Gist options
  • Save svs/4312838 to your computer and use it in GitHub Desktop.
Save svs/4312838 to your computer and use it in GitHub Desktop.
QuotationsIndexParams
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