Permalink
Browse files

set now supports blocks

  • Loading branch information...
1 parent ca7838d commit c94da0979051f5095a4d2d376173a54027bd53c5 @rkh committed Mar 26, 2010
Showing with 4 additions and 4 deletions.
  1. +2 −2 README.md
  2. +2 −2 lib/sinatra/sugar.rb
View
@@ -27,14 +27,14 @@ More advanced set
set :haml, :excape_html => false
haml # => { :format => :html5, :escape_html => false }
-- Allowes passing a block:
+- Allows passing a block in Sinatra 0.9, too:
set(:foo) { Time.now }
More advanced register
----------------------
-If an exntesion is registered twice, the registered hook will only be called once.
+If an extension is registered twice, the registered hook will only be called once.
Ability to extend command line options
--------------------------------------
@@ -34,11 +34,11 @@ module ClassMethods
# set :haml, :format => :html5, :escape_html => true
# set :haml, :excape_html => false
# haml # => { :format => :html5, :escape_html => false }
- # - Allowes passing a block:
+ # - Allowes passing a block (for Sinatra 0.9.x):
# set(:foo) { Time.now }
def set(key, value = self, &block)
# FIXME: refactor, refactor, refactor
- if block_given?
+ if block_given? and Sinatra::VERSION < "1.0"
raise ArgumentError, "both a value and a block given" if value != self
value = block
end

0 comments on commit c94da09

Please sign in to comment.