[前][次][番号順一覧][スレッド一覧]

ruby-changes:6162

From: kou <ko1@a...>
Date: Sun, 29 Jun 2008 17:47:55 +0900 (JST)
Subject: [ruby-changes:6162] Ruby:r17674 (trunk): * lib/rss/parser.rb (RSS::ListenerMixin#known_class): define to

kou	2008-06-29 17:44:53 +0900 (Sun, 29 Jun 2008)

  New Revision: 17674

  Modified files:
    trunk/ChangeLog
    trunk/lib/rss/parser.rb

  Log:
    * lib/rss/parser.rb (RSS::ListenerMixin#known_class): define to
      work with ruby 1.8.x too.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17674&r2=17673&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rss/parser.rb?r1=17674&r2=17673&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17673)
+++ ChangeLog	(revision 17674)
@@ -1,3 +1,8 @@
+Sun Jun 29 17:44:23 2008  Kouhei Sutou  <kou@c...>
+
+	* lib/rss/parser.rb (RSS::ListenerMixin#known_class): define to
+	work with ruby 1.8.x too.
+
 Sun Jun 29 17:41:42 2008  Kouhei Sutou  <kou@c...>
 
 	* lib/rss/maker/base.rb (RSS::Maker::RSSBase#to_feed): raise
Index: lib/rss/parser.rb
===================================================================
--- lib/rss/parser.rb	(revision 17673)
+++ lib/rss/parser.rb	(revision 17674)
@@ -361,9 +361,7 @@
     def start_else_element(local, prefix, attrs, ns)
       class_name = self.class.class_name(_ns(ns, prefix), local)
       current_class = @last_element.class
-      if class_name and
-          (current_class.const_defined?(class_name, false) or
-           current_class.constants.include?(class_name.to_sym))
+      if known_class?(current_class, class_name)
         next_class = current_class.const_get(class_name)
         start_have_something_element(local, prefix, attrs, ns, next_class)
       else
@@ -379,6 +377,20 @@
       end
     end
 
+    if Module.method(:const_defined?).arity == -1
+      def known_class?(target_class, class_name)
+        class_name and
+          (target_class.const_defined?(class_name, false) or
+           target_class.constants.include?(class_name.to_sym))
+      end
+    else
+      def known_class?(target_class, class_name)
+        class_name and
+          (target_class.const_defined?(class_name) or
+           target_class.constants.include?(class_name))
+      end
+    end
+
     NAMESPLIT = /^(?:([\w:][-\w\d.]*):)?([\w:][-\w\d.]*)/
     def split_name(name)
       name =~ NAMESPLIT

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]