molten-trunk/molten5_withgrid/app/models/case_report.rb
# Takes a hash and finds the matching saved report if it exists.
# 
# Examples
# 
#   CaseReport.match_existing({"baz"=>"bing"}) #=> nil
#   CaseReport.match_existing({"foo"=>"bar"}) #=> #<CaseReport>
# 
# Returns <tt>nil</tt> if no matching saved report was found, otherwise
# it returns the instance of the matching case report.
# 
Takes a hash and finds the matching saved report if it exists.
Examples



Returns nil if no matching saved report was found, otherwise
it returns the instance of the matching case report.
Takes a hash and finds the matching saved report if it exists . Examples Returns nil if no matching saved report was found otherwise it returns the instance of the matching case report .
def match_existing(contact_id, query)
      query = self.to_options(query)
      if reports = self.find(:all, :conditions => ["contact_id = ?", contact_id], :readonly => true, :select => 'id, query')
        reports.each do |report|
          return self.find(report.id) if report.to_options == query.reject { |k, v| NON_QUERY_KEYS.include?(k) }
        end
        return nil
      end
    end
def match_existing ( contact_id , query ) query = self . to_options ( query ) if reports = self . find ( :all , :conditions => [ "contact_id = ?" , contact_id ] , :readonly => true , :select => 'id, query' ) reports . each do | report | return self . find ( report . id ) if report . to_options == query . reject { | k , v | NON_QUERY_KEYS . include? ( k ) } end return nil end end
Takes a hash and finds the matching saved report if it exists.
Takes a hash and finds the matching saved report if it exists .
contact_id
query