Closed kamui closed 11 years ago
This is a tricky one since describing services is the core feature of WD and having to namespace the method call ends up making things more annoying. That said we could take the approach I took for BubbleWrap and create an WD
alias for WeaselDiesel
and therefore reduce the amount of code to type on each service description.
That's fine by me. It's up to you, I don't mind too much either way, but the WD alias sounds reasonable to me.
Either way, I think we can merge this PR, since it just extracts the DSL into it's own class and makes describe_service
only available within main
.
Currently, the
describe_service
method extends Kernel, but as we probably will need to expand the DSL for default errors and meta API information, we probably shouldn't pollute every object with our DSL, so instead this PR extends the the top levelmain
object only. I borrowed this fromrake
, which extends it's DSL in the same way.It's not immediately obvious to me when any user would need to define an API within another class or namespace. If so, they could always include or extend
WeaselDiesel::DSL
like I do in thespec_helper
so you can define services specs.To take it one step further, maybe we shouldn't extend
main
either. Maybe you should be forced toWeasalDiesel.describe_service
orWeasalDiesel::DSL.describe_service
. I know rspec 3 is taking this route instead of monkey patching.