mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Convert Template::Types.type_klass to instance ivar
This commit is contained in:
parent
6d624c648c
commit
33e054edbc
1 changed files with 14 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue