mattetti / Weasel-Diesel

DSL to describe, document and test web services
MIT License
438 stars 21 forks source link

Only extend top level main object with the DSL #31

Closed kamui closed 11 years ago

kamui commented 11 years ago

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 level main object only. I borrowed this from rake, 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 the spec_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 to WeasalDiesel.describe_service or WeasalDiesel::DSL.describe_service. I know rspec 3 is taking this route instead of monkey patching.

mattetti commented 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.

kamui commented 11 years ago

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.