Hi. This is probably OT because it's really a Moose question, and only incidentally in a Catalyst context, but I'd be grateful for any pointers. This is sort of a followup to a question that's discussed, well and thoroughly, on Stack Overflow, but without providing the answer I need: https://stackoverflow.com/questions/40243560/moose-accessors-in-catalyst-cant-use-string-as-hash-ref-error
I'm in a pretty similar situation: I have a Catalyst model, which doesn't in fact need to be an actual Catalyst model (that is, I could move it outside the Model namespace to "Utility" or something, and it would be OK). I want to use MooseX::LogDispatch from within this. Basically: ---package MyApp::Model::Email;use Moose; use namespace::autoclean;with 'MooseX::LogDispatch'; extends Catalyst::Model; # maybe this isn't needed, and I could move the package has log_dispatch_conf => ( # config setup here--NOT using any Cat config); sub generate_bcc_line { my ($self, @args) = @_; $self->logger->info("Generating bcc line"); # ...--- As in the Stack Overflow question, if I try calling send_email() from a test script with "MyApp::Model::Email->generate_bcc_line", I get the "Can't use string ("MyApp::Model::Email") as a HASH ref" error. If, in the test script, I get $c with the $ctx_request thing, and call $c->model('Email')->generate_bcc_line, then it works. I'm pretty new to Moose, and don't understand how I could be integrating this into my package. My question is: What if I WANT to call this from outside Catalyst? That is, suppose I move MyApp::Model::Email to MyApp::Utility::Email, so I can call it from a cronjob or something. How do I get LogDispatch to work? I'd still want to log things even in a non-web context. But if my outside script has "use MyApp::Utility::Email->generate_bcc_line", LogDispatch will error too. But since LogDispatch isn't connected to Catalyst, there must be a way to use it the way I'm suggesting. What is that way? Thank you. Jen
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/