README.rdoc in rubyless-0.1.0 vs README.rdoc in rubyless-0.2.0
- old
+ new
@@ -33,14 +33,19 @@
safe_method :node => lambda {|h| {:class => h.context[:node_class], :method => h.context[:node]}}
safe_method [:strftime, Time, String] => String
safe_method_for String, [:==, String] => RubyLess::Boolean
safe_method_for String, [:to_s] => String
-You can also redefine 'safe_method?' for any class or for the main helper in order to do some more complicated renaming. Note
+You can also redefine 'safe_method_type' for any class or for the main helper in order to do some more complicated renaming. Note
also that you should add ':nil => true' declaration to any method that could return a nil value so that RubyLess can render
code that will not break during runtime (adding nil checking in the form of "foo ? foo.name : nil").
+Or you can group all declarations in a single place with 'safe_method_for':
+
+ RubyLess::SafeClass.safe_method_for Dummy, :prev => {:class => Dummy, :method => 'previous', :nil => true},
+ :node => lambda {|h| {:class => h.context[:node_class], :method => h.context[:node]}}
+
You can now parse some ruby code:
RubyLess.translate("!prev.ancestor?(main) && !node.ancestor?(main)", self)
=> "(not previous.ancestor?(@node) and not var1.ancestor?(@node))"
@@ -51,11 +56,10 @@
=> "strftime(Time.now, \"%Y\")"
RubyLess.translate("log_info(spouse, spouse.name)", self)
=> "(var1.spouse ? log_info(var1.spouse, var1.spouse.name) : nil)"
-Since most of the code in SafeClass is string evaluated (to scope class variables), there is not much to parse for rdoc. You
-can look at the tests for an idea of how to declare things. If you have more questions, ask on zena's mailing list:
+You can look at the tests for an idea of how to declare things. If you have more questions, ask on zena's mailing list:
http://zenadmin.org/community
== REQUIREMENTS:
\ No newline at end of file