瀏覽代碼

OpenStruct responds to `[]`/`[]=` in Ruby 2.0+

Akinori MUSHA 9 年之前
父節點
當前提交
010a3c093e
共有 1 個文件被更改,包括 0 次插入15 次删除
  1. 0 15
      app/models/scenario_import.rb

+ 0 - 15
app/models/scenario_import.rb

@@ -278,21 +278,6 @@ class ScenarioImport
       yield 'disabled', disabled, boolean if disabled.requires_merge?
     end
 
-    # Unfortunately Ruby 1.9's OpenStruct doesn't expose [] and []=.
-    unless instance_methods.include?(:[]=)
-      def [](key)
-        self.send(sanitize key)
-      end
-
-      def []=(key, val)
-        self.send("#{sanitize key}=", val)
-      end
-
-      def sanitize(key)
-        key.gsub(/[^a-zA-Z0-9_-]/, '')
-      end
-    end
-
     def agent_instance
       "Agents::#{self.type.updated}".constantize.new
     end