Skip to content

Commit

Permalink
set now supports blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Mar 26, 2010
1 parent ca7838d commit c94da09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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
--------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions lib/sinatra/sugar.rb
Expand Up @@ -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
Expand Down

0 comments on commit c94da09

Please sign in to comment.