来自:http://blog.nofail.de/2010/02/writing-your-own-dsl-with-ruby/
?
Some Rules from wrting your own dsl with ruby
?
1. let the user choose how to use it
?
all implemented methods return the object instance itself,so one can chain method calls for convenient
?
2. make options optional
?
a well designed API does not force user to provide argument that are not mandatory
?
3. make use of an option hash for defaults
?
consider using an optional parameter hash as the last method argument
?
4. make use of scoped blocks
?
providing scopes is another way to improve the readability of your code
?
5. make use of instance_eval
?
rebuid do?
method1
method2
method3?
end
?
6. consider implementing method_missing