-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Łukasz Śliwa
committed
Feb 12, 2012
1 parent
f7fb74a
commit 7a8bed7
Showing
5 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ tmtags | |
## VIM | ||
*.swp | ||
|
||
## RUBYMINE | ||
.idea | ||
|
||
## PROJECT::GENERAL | ||
coverage | ||
doc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Grape | ||
class Cookies | ||
|
||
def initialize | ||
@send = true | ||
@cookies = {} | ||
@send_cookies = {} | ||
end | ||
|
||
def without_send | ||
@send = false | ||
yield self if block_given? | ||
@send = true | ||
end | ||
|
||
def [](name) | ||
@cookies[name] | ||
end | ||
|
||
def []=(name, value) | ||
@cookies[name.to_sym] = value | ||
@send_cookies[name.to_sym] = true if @send | ||
end | ||
|
||
def each(opt = nil, &block) | ||
if opt == :to_send | ||
@cookies.select { |key, value| | ||
@send_cookies[key.to_sym] == true | ||
}.each(&block) | ||
else | ||
@cookies.each(&block) | ||
end | ||
end | ||
|
||
def delete(name) | ||
self.[]=(name, { :value => 'deleted', :expires => Time.at(0) }) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters