raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] Add method_missing to Raindrops::Middleware::Proxy
@ 2012-05-18  1:46 Ben Somers
  2012-05-18  2:35 ` Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Somers @ 2012-05-18  1:46 UTC (permalink / raw)
  To: raindrops

This enables it to behave more like a Rack
BodyProxy would, delegating methods to its body
object when it does not implement them itself.
(Also includes  a minor grammar fix to a comment.)
---
Here you go! Hopefully this is a patch format you appreciate?
Guidelines are a little less clear than on unicorn :p.

 lib/raindrops/middleware/proxy.rb |   11 +++++++++--
 test/test_middleware.rb           |    4 ++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/raindrops/middleware/proxy.rb
b/lib/raindrops/middleware/proxy.rb
index 53e14b5..51be3eb 100644
--- a/lib/raindrops/middleware/proxy.rb
+++ b/lib/raindrops/middleware/proxy.rb
@@ -1,7 +1,7 @@
 # -*- encoding: binary -*-
 # :stopdoc:
-# This class is by Raindrops::Middleware to proxy application response
-# bodies.  There should be no need to use it directly.
+# This class is used by Raindrops::Middleware to proxy application
+# response bodies.  There should be no need to use it directly.
 class Raindrops::Middleware::Proxy
   def initialize(body, stats)
     @body, @stats = body, stats
@@ -31,4 +31,11 @@ class Raindrops::Middleware::Proxy
     m = m.to_sym
     :close == m || @body.respond_to?(m)
   end
+
+  # Rack::BodyProxy objects use +method_missing+ to delegate methods
+  # to their bodies
+  def method_missing(*args, &block)
+    @body.send(*args, &block)
+  end
+
 end
diff --git a/test/test_middleware.rb b/test/test_middleware.rb
index eedf04a..56ce346 100644
--- a/test/test_middleware.rb
+++ b/test/test_middleware.rb
@@ -120,5 +120,9 @@ class TestMiddleware < Test::Unit::TestCase
     def orig_body.to_path; "/dev/null"; end
     assert body.respond_to?(:to_path)
     assert_equal "/dev/null", body.to_path
+
+    def orig_body.body; "this is a body"; end
+    assert body.respond_to?(:body)
+    assert_equal "this is a body", body.body
   end
 end
-- 
1.7.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add method_missing to Raindrops::Middleware::Proxy
  2012-05-18  1:46 [PATCH] Add method_missing to Raindrops::Middleware::Proxy Ben Somers
@ 2012-05-18  2:35 ` Eric Wong
  2012-05-18  3:56   ` Ben Somers
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2012-05-18  2:35 UTC (permalink / raw)
  To: raindrops

Ben Somers <somers.ben@gmail.com> wrote:
> This enables it to behave more like a Rack
> BodyProxy would, delegating methods to its body
> object when it does not implement them itself.
> (Also includes  a minor grammar fix to a comment.)
> ---
> Here you go! Hopefully this is a patch format you appreciate?

Thanks!  (minor nits below)

> Guidelines are a little less clear than on unicorn :p.

Sorry :x  I try to follow the contribution guidelines as git itself and
I think the README makes that much clear.  Patches to clarify what you
think needs clarifying also appreciated :)

I tend to be less good (and less picky :) than Junio when it comes to
grammar, though.

> --- a/lib/raindrops/middleware/proxy.rb
> +++ b/lib/raindrops/middleware/proxy.rb
>    end
> +
> +  # Rack::BodyProxy objects use +method_missing+ to delegate methods
> +  # to their bodies

I don't think the comment makes sense without the context of this email
thread/commit message.  Perhaps the following?

   # Avoid breaking users of non-standard extensions (e.g. #body)
   # Rack::BodyProxy does the same.

> +  def method_missing(*args, &block)
> +    @body.send(*args, &block)
> +  end
> +
>  end

I don't think I usually add a blank line between after the last method
and the end of a class/module.  Trivial fix on my end.

Let me know if you think my comment for method_missing is better.
(often things I say which I /think/ makes sense... don't :D)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add method_missing to Raindrops::Middleware::Proxy
  2012-05-18  2:35 ` Eric Wong
@ 2012-05-18  3:56   ` Ben Somers
  2012-05-18  4:27     ` Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Somers @ 2012-05-18  3:56 UTC (permalink / raw)
  To: raindrops

> Sorry :x  I try to follow the contribution guidelines as git itself and
> I think the README makes that much clear.  Patches to clarify what you
> think needs clarifying also appreciated :)

Hah, still pretty clear. I'm just used to working on github-hosted
projects, where pull requests are the norm. Sitting down and reading
through git's guidelines takes a minute.

> Let me know if you think my comment for method_missing is better.
> (often things I say which I /think/ makes sense... don't :D)

I agree, I like your version better. And I think the blank line was an
accident anyway :)

-ben

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add method_missing to Raindrops::Middleware::Proxy
  2012-05-18  3:56   ` Ben Somers
@ 2012-05-18  4:27     ` Eric Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2012-05-18  4:27 UTC (permalink / raw)
  To: raindrops

Ben Somers <somers.ben@gmail.com> wrote:
> > Sorry :x  I try to follow the contribution guidelines as git itself and
> > I think the README makes that much clear.  Patches to clarify what you
> > think needs clarifying also appreciated :)
> 
> Hah, still pretty clear. I'm just used to working on github-hosted
> projects, where pull requests are the norm. Sitting down and reading
> through git's guidelines takes a minute.

Cool, thanks for taking the time, though :)

> > Let me know if you think my comment for method_missing is better.
> > (often things I say which I /think/ makes sense... don't :D)
> 
> I agree, I like your version better. And I think the blank line was an
> accident anyway :)

Pushed.  I'm thinking about making another raindrops release in the next
day or two for this.  Any other changes?


I'm not sure if I'll get to the unix_diag addition that landed in
Linux 3.3 (any takers? :).  unix_diag can wait since it'll be a while
before people upgrade to 3.3.  (I still support systems on 2.6.18).

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-18  4:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-18  1:46 [PATCH] Add method_missing to Raindrops::Middleware::Proxy Ben Somers
2012-05-18  2:35 ` Eric Wong
2012-05-18  3:56   ` Ben Somers
2012-05-18  4:27     ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/raindrops.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).