sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit bbf48f75edf47b18da8fd71b3834fcef1d59d941
parent db1aa1429d96745b8a0c5f030a2170d71f8dfd86
Author: Whyme Lyu <callme5long@gmail.com>
Date:   Tue, 28 May 2013 23:48:17 +0800

Remove redundant self.instance_eval

Diffstat:
M lib/sup.rb | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -22,30 +22,27 @@ end
 class Module
   def yaml_properties *props
     props = props.map { |p| p.to_s }
-    klass = self
 
-    klass.instance_eval do
-      def self.to_yaml_tag
-        path = name.gsub(/::/, "/")
-        "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"
-      end
+    def self.to_yaml_tag
+      path = name.gsub(/::/, "/")
+      "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"
+    end
 
-      define_method(:to_yaml_type) { self.class.to_yaml_tag }
-      define_method :init_with do |coder|
-        initialize(*coder.map.values_at(*props))
-      end
-      
-      define_method :encode_with do |coder|
-        coder.map = props.inject({}) do |hash, key|
-          hash[key] = instance_variable_get("@#{key}")
-          hash
-        end
-      end
+    define_method(:to_yaml_type) { self.class.to_yaml_tag }
+    define_method :init_with do |coder|
+      initialize(*coder.map.values_at(*props))
+    end
 
-      yaml_tag to_yaml_tag
-      path = name.gsub(/::/, "/")
-      Psych.load_tags["!#{Redwood::LEGACY_YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"] = self
+    define_method :encode_with do |coder|
+      coder.map = props.inject({}) do |hash, key|
+        hash[key] = instance_variable_get("@#{key}")
+        hash
+      end
     end
+
+    yaml_tag to_yaml_tag
+    path = name.gsub(/::/, "/")
+    Psych.load_tags["!#{Redwood::LEGACY_YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"] = self
   end
 end