Where to call DataMapper.finalize?

18 views
Skip to first unread message

Philip How

unread,
Aug 20, 2014, 5:29:16 AM8/20/14
to pak...@googlegroups.com
Hey all,

First off, thanks for making Pakyow, it's awesome!

Secondly, where's the "correct" place to call DataMapper.finalize? It appears the code in app.rb is called before my other Ruby files (where my model is defined). For now I've stuck it at the end of the file where my model is defined... This works but it feels a bit out of place!

Any suggestions?

Bryan Powell

unread,
Aug 20, 2014, 8:34:35 AM8/20/14
to pak...@googlegroups.com
Hi Philip,

There are actually hooks that execute as the app does things. I'd recommend tying into these. Here's an example: https://gist.github.com/bryanp/9b65afd5c55116dd8d1b

And here's a full list of hooks (all before/after except as noted):
  • init: wraps app initialization; only called once no matter the configuration
    • load: called when the app is loaded (on startup, and every request if `auto_reload` is turned on)
  • process: wraps request handling
    • route: wraps the routing step of `process`
      • match (this is only an after hook): called after a route is successfully matched
    • error: wraps the handling of an exception raised by a Pakyow app
Hope this helps. Glad you're enjoying Pakyow!

Bryan P.


--
You received this message because you are subscribed to the Google Groups "Pakyow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pakyow+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages