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
278 278
       yield 'disabled', disabled, boolean if disabled.requires_merge?
279 279
     end
280 280
 
281
-    # Unfortunately Ruby 1.9's OpenStruct doesn't expose [] and []=.
282
-    unless instance_methods.include?(:[]=)
283
-      def [](key)
284
-        self.send(sanitize key)
285
-      end
286
-
287
-      def []=(key, val)
288
-        self.send("#{sanitize key}=", val)
289
-      end
290
-
291
-      def sanitize(key)
292
-        key.gsub(/[^a-zA-Z0-9_-]/, '')
293
-      end
294
-    end
295
-
296 281
     def agent_instance
297 282
       "Agents::#{self.type.updated}".constantize.new
298 283
     end