Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use 'delegate' macro instead of writing out methods by hand #1909

Merged
merged 1 commit into from

2 participants

@r00k

New code is shorter and more intention-revealing.

@josevalim josevalim merged commit 3dedf5f into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 29, 2011
  1. @r00k
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 24 deletions.
  1. +2 −24 actionpack/lib/action_dispatch/middleware/flash.rb
View
26 actionpack/lib/action_dispatch/middleware/flash.rb
@@ -73,6 +73,8 @@ def notice=(message)
class FlashHash
include Enumerable
+ delegate :[], :keys, :key?, :empty?, :clear, :each, :to => :@flashes
+
def initialize #:nodoc:
@used = Set.new
@closed = false
@@ -94,24 +96,12 @@ def []=(k, v) #:nodoc:
@flashes[k] = v
end
- def [](k)
- @flashes[k]
- end
-
def update(h) #:nodoc:
h.keys.each { |k| keep(k) }
@flashes.update h
self
end
- def keys
- @flashes.keys
- end
-
- def key?(name)
- @flashes.key? name
- end
-
def delete(key)
@flashes.delete key
self
@@ -121,18 +111,6 @@ def to_hash
@flashes.dup
end
- def empty?
- @flashes.empty?
- end
-
- def clear
- @flashes.clear
- end
-
- def each(&block)
- @flashes.each(&block)
- end
-
alias :merge! :update
def replace(h) #:nodoc:
Something went wrong with that request. Please try again.