Skip to content

Instantly share code, notes, and snippets.

@arc
Created November 5, 2014 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arc/81a06d2842cb5b754942 to your computer and use it in GitHub Desktop.
Save arc/81a06d2842cb5b754942 to your computer and use it in GitHub Desktop.
for my $source_name (__PACKAGE__->sources) {
my $method_name = lc($source_name =~ s/(?<=.)(?=[A-Z])/_/axmsgr);
s/(?<![aeiou])y$/ies/axms or s/(?:ss|s|sh|ch|x)\K\z/es/axms or s/\z/s/axms
for $method_name; # XXX: perhaps use Lingua::EN::Inflect or similar?
my $method = sub {
my $rs = shift->resultset($source_name);
return @_ ? $rs->search_rs(@_) : $rs;
};
no strict 'refs';
*$method_name = $method;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment