aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-13 18:49:53 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-13 18:49:53 -0700
commit4a7b11d5d857a0f5ce6eb8af7a6dfcb94f31fcfa (patch)
tree45a99d0a57695ff5c0e5c96a54b86932c3fda40c /actionpack/lib
parent2f998fc81fd3525e4f19ba55937ee423c4b71856 (diff)
downloadrails-4a7b11d5d857a0f5ce6eb8af7a6dfcb94f31fcfa.tar.gz
rails-4a7b11d5d857a0f5ce6eb8af7a6dfcb94f31fcfa.tar.bz2
rails-4a7b11d5d857a0f5ce6eb8af7a6dfcb94f31fcfa.zip
Less ceremony
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/body_parts/concurrent_block.rb25
-rw-r--r--actionpack/lib/action_view/body_parts/future.rb10
-rw-r--r--actionpack/lib/action_view/body_parts/queued.rb18
-rw-r--r--actionpack/lib/action_view/body_parts/threaded.rb32
4 files changed, 25 insertions, 60 deletions
diff --git a/actionpack/lib/action_view/body_parts/concurrent_block.rb b/actionpack/lib/action_view/body_parts/concurrent_block.rb
new file mode 100644
index 0000000000..28a3a3bf4d
--- /dev/null
+++ b/actionpack/lib/action_view/body_parts/concurrent_block.rb
@@ -0,0 +1,25 @@
+module ActionView
+ module BodyParts
+ class ConcurrentBlock
+ def initialize(&block)
+ @block = block
+ @body = []
+ start
+ end
+
+ def to_s
+ finish
+ @body.join
+ end
+
+ protected
+ def start
+ @worker = Thread.new { @block.call(@body) }
+ end
+
+ def finish
+ @worker.join if @worker && @worker.alive?
+ end
+ end
+ end
+end
diff --git a/actionpack/lib/action_view/body_parts/future.rb b/actionpack/lib/action_view/body_parts/future.rb
deleted file mode 100644
index f03c2b395b..0000000000
--- a/actionpack/lib/action_view/body_parts/future.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module ActionView
- module BodyParts
- class Future
- def to_s
- finish
- body
- end
- end
- end
-end
diff --git a/actionpack/lib/action_view/body_parts/queued.rb b/actionpack/lib/action_view/body_parts/queued.rb
deleted file mode 100644
index 618999742b..0000000000
--- a/actionpack/lib/action_view/body_parts/queued.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'action_view/body_parts/future'
-
-module ActionView
- module BodyParts
- class Queued < Future
- attr_reader :body
-
- def initialize(job)
- @receipt = enqueue(job)
- end
-
- protected
- def finish
- @body = redeem(@receipt)
- end
- end
- end
-end
diff --git a/actionpack/lib/action_view/body_parts/threaded.rb b/actionpack/lib/action_view/body_parts/threaded.rb
deleted file mode 100644
index a2347a2f0e..0000000000
--- a/actionpack/lib/action_view/body_parts/threaded.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'action_view/body_parts/future'
-
-module ActionView
- module BodyParts
- class Threaded < Future
- def initialize(concurrent = false, &block)
- @block = block
- @parts = []
- concurrent ? start : work
- end
-
- protected
- def work
- @block.call(@parts)
- end
-
- def body
- str = ''
- @parts.each { |part| str << part.to_s }
- str
- end
-
- def start
- @worker = Thread.new { work }
- end
-
- def finish
- @worker.join if @worker && @worker.alive?
- end
- end
- end
-end