yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] http_client: implement as a module instead of class
@ 2014-12-20  4:11 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2014-12-20  4:11 UTC (permalink / raw)
  To: yahns-public

This allows us to more easilly override and invoke super
via other included modules.
---
 lib/yahns/acceptor.rb    | 2 +-
 lib/yahns/http_client.rb | 2 +-
 lib/yahns/rack.rb        | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/yahns/acceptor.rb b/lib/yahns/acceptor.rb
index cd9e055..3e67aba 100644
--- a/lib/yahns/acceptor.rb
+++ b/lib/yahns/acceptor.rb
@@ -43,7 +43,7 @@ module Yahns::Acceptor # :nodoc:
         queue = client_class.queue
         t = Thread.current
         accept_flags = Kgio::SOCK_NONBLOCK | Kgio::SOCK_CLOEXEC
-        qev_flags = client_class.superclass::QEV_FLAGS
+        qev_flags = client_class.const_get(:QEV_FLAGS)
         begin
           # We want the accept/accept4 syscall to be _blocking_
           # so it can distribute work evenly between processes
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index a294511..371182e 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -1,7 +1,7 @@
 # -*- encoding: binary -*-
 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-class Yahns::HttpClient < Kgio::Socket # :nodoc:
+module Yahns::HttpClient # :nodoc: < Kgio::Socket # :nodoc:
   NULL_IO = StringIO.new("")
 
   # FIXME: we shouldn't have this at all
diff --git a/lib/yahns/rack.rb b/lib/yahns/rack.rb
index 3f8f6b7..2b1a0f4 100644
--- a/lib/yahns/rack.rb
+++ b/lib/yahns/rack.rb
@@ -39,7 +39,8 @@ class Yahns::Rack # :nodoc:
   end
 
   def config_context
-    ctx_class = Class.new(Yahns::HttpClient)
+    ctx_class = Class.new(Kgio::Socket)
+    ctx_class.__send__(:include, Yahns::HttpClient)
     ctx_class.extend(Yahns::HttpContext)
     ctx_class.http_ctx_init(self)
     ctx_class
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-20  4:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-20  4:11 [PATCH] http_client: implement as a module instead of class Eric Wong

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

	https://yhbt.net/yahns.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).