plexus / hexp

Ruby virtual DOM for HTML
MIT License
56 stars 3 forks source link

Auto-detect DSL methods #17

Closed plexus closed 11 years ago

plexus commented 11 years ago

when you do a include Hexp in your object, that will actually delegate to including Hexp::DSL, which defines makes your object duck-type compatible with a Hexp::Node by delegating all DSL methods to #to_hexp.

Currently Hexp::DSL contains a list of methods that it should forward, and I believe it is already out of date.

I split up the API for Node into an Attributes module and a Children module that are mixed in to Node. These define the operation that work on attributes (add_class, merge_attrs, etc), versus those that work on child nodes (add_child, empty?, map_children.)

I would like Hexp::DSL to use some meta-programming to detect all methods defined in Hexp::Node::Attributes and Hexp::Node::Children, and delegate those automatically. The ones defines in Hexp::Node itself can still be manually listed, these will change less often, and we don't want to delegate all of them (initialize, to_hexp are excluded for instance).