C0 code coverage information
Generated on Wed Jul 30 00:45:18 -0400 2008 with
rcov 0.8.1.2
Code reported as executed by Ruby looks like
this... and this: this line is also marked as
covered. Lines considered as run by rcov, but
not reported by Ruby, look like this, and
this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not
executed.
1
module DBI 2 class
Collection 3 def
initialize( the_one, the_many_model, the_one_fk ) 4 @the_one = the_one 5 @the_many_model = the_many_model
6 @the_one_fk = the_one_fk
7 end 8 9 def elements 10 @the_many_model.where( @the_one_fk => @the_one.pk )
11 end 12 alias copy elements 13 14 def method_missing( method, *args, &blk )
15 elements.send( method,
*args, &blk ) 16 end
17 18 def push( new_item_hash )
19 new_item_hash[
@the_one_fk ] = @the_one.pk 20 @the_many_model.create( new_item_hash ) 21 end 22 alias << push 23 alias add push 24 25 def delete( arg ) 26 case arg 27 when @the_many_model 28 result = @the_many_model.dbh.do( 29 %{ 30 DELETE FROM #{@the_many_model.table} 31 WHERE 32 #{@the_one_fk} = ? 33 AND #{@the_many_model.pk} = ?
34 }, 35 @the_one.pk, 36 arg.pk 37 ) 38 result > 0 39 when Hash 40 hash = arg 41 keys = hash.keys 42 where_subclause = keys.map { |k| 43 "#{k} = ?" 44 }.join( " AND " )
45 @the_many_model.dbh.do(
46 %{ 47 DELETE FROM #{@the_many_model.table}
48 WHERE 49 #{@the_one_fk} = ? 50 AND #{where_subclause}
51 }, 52 @the_one.pk, 53 *( keys.map { |k| hash[ k ] } )
54 ) 55 end 56 end 57 58 # Returns the number of records deleted 59 def clear 60 @the_many_model.dbh.do( 61 %{ 62 DELETE FROM #{@the_many_model.table} 63 WHERE #{@the_one_fk} = ?
64 }, 65 @the_one.pk 66 ) 67 end 68 end 69 end
Generated using the rcov
code coverage analysis tool for Ruby version 0.8.1.2.