<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1502990270667_6215">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:</div><div id="yui_3_16_0_ym19_1_1502990270667_6214"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><a href="https://stackoverflow.com/questions/40243560/moose-accessors-in-catalyst-cant-use-string-as-hash-ref-error" class="" id="yui_3_16_0_ym19_1_1502990270667_6134">https://stackoverflow.com/questions/40243560/moose-accessors-in-catalyst-cant-use-string-as-hash-ref-error</a><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">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:</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">---</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">package MyApp::Model::Email;</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">use Moose;&nbsp;</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">use namespace::autoclean;</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">with 'MooseX::LogDispatch';</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">extends Catalyst::Model; # maybe this isn't needed, and I could move the package</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">has log_dispatch_conf =&gt; ( # config setup here--NOT using any Cat config);</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">sub generate_bcc_line {</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">&nbsp; my ($self, @args) = @_;</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">&nbsp; $self-&gt;logger-&gt;info("Generating bcc line");</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">&nbsp; # ...</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">---</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">As in the Stack Overflow question, if I try calling send_email() from a test script with "MyApp::Model::Email-&gt;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-&gt;model('Email')-&gt;generate_bcc_line, then it works.</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">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-&gt;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?</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">Thank you.</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr">Jen</div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6128" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6212"><br></div><div id="yui_3_16_0_ym19_1_1502990270667_6211"><br></div></div></body></html>