On Fri, 2007-06-22 at 08:42 +1000, Charlie Garrison wrote: > Good morning,
In Australia. > For one of my classes I want to extend the 'find' method so that > only records belonging to current user will be found. I could > use 'search' and compose the query, but I would prefer to keep > semantics of 'find' (cleaner code and all that). > > I have tried overriding 'find' in the specific class, but it's > not getting called. I'm still wrapping my head around > differences in schema, result_source, result_set, row, etc. and > which methods each uses. I'm not sure where to put the > overriding methods for each of those. > > So, first my question is, what is the best way to extend find so > that I can restrict records using an additional (constant) value > in the query? And if I should just override 'find', where do I > put my 'find' method? find is a ResultSet method; you need to create a ResultSet class that inherits from DBIx::Class::ResultSet, put your find in there (and probably search_rs too), and direct your schema to use that class by adding __PACKAGE__->resultset_class(...) into your schema (table declaration) class. -- Jon _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
