Skip to content

Commit

Permalink
RubyLess safe 'advance' on Time class.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Apr 11, 2011
1 parent 0ebd3dc commit 63c18c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/zena/use/zafu_safe_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ def self.join_proc
safe_method_for NilClass, :to_i => {:class => Number, :pre_processor => true}
safe_method_for Object, :blank? => Boolean

safe_method_for Time, [:advance, {
:years => Number,
:months => Number,
:weeks => Number,
:days => Number,
:hours => Number,
:minutes => Number,
:seconds => Number}] => Time

safe_method_for Node, [:kind_of?, VirtualClass] =>
{:method => 'nil', :nil => true, :pre_processor => kind_of_proc}
safe_method_for Node, [:kind_of?, Role] =>
Expand Down
8 changes: 7 additions & 1 deletion test/integration/zafu_compiler/safe_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ max:
h: 10
w: 0.1
src: "<r:show format='%.2f CHF' eval='params[:h].to_f * max(0.25, 10 * params[:w].to_f)'/>"
res: "10.00 CHF"
res: "10.00 CHF"

time_advance:
context:
date: '2011-02-03'
src: "<b do='main_date.advance(:months => 1).strftime(\"%Y-%m-%d\")'/>"
res: "<b>2011-03-03</b>"

0 comments on commit 63c18c2

Please sign in to comment.