From 33e054edbcc954ee6a6bcfba8aea1f0d1a1a3031 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 15 Apr 2021 17:56:39 -0700 Subject: [PATCH] Convert Template::Types.type_klass to instance ivar --- actionview/lib/action_view/template/types.rb | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/actionview/lib/action_view/template/types.rb b/actionview/lib/action_view/template/types.rb index 67b7a62de6..33b9560c42 100644 --- a/actionview/lib/action_view/template/types.rb +++ b/actionview/lib/action_view/template/types.rb @@ -4,7 +4,7 @@ require "active_support/core_ext/module/attribute_accessors" module ActionView class Template #:nodoc: - class Types + module Types class Type SET = Struct.new(:symbols).new([ :html, :text, :js, :css, :xml, :json ]) @@ -37,21 +37,23 @@ module ActionView end end - cattr_accessor :type_klass + class << self + attr_accessor :type_klass - def self.delegate_to(klass) - self.type_klass = klass + def delegate_to(klass) + self.type_klass = klass + end + + def [](type) + type_klass[type] + end + + def symbols + type_klass::SET.symbols + end end delegate_to Type - - def self.[](type) - type_klass[type] - end - - def self.symbols - type_klass::SET.symbols - end end end end