Sha256: f4b4ffbbaf56003c398b2928f7b13f1da18b8aa76dba3620a9f6eb629b3a60dd
Contents?: true
Size: 1.07 KB
Versions: 96
Compression:
Stored size: 1.07 KB
Contents
require 'set' require 'active_support/core_ext/module/attribute_accessors' module ActionView class Template class Types class Type cattr_accessor :types self.types = Set.new def self.register(*t) types.merge(t.map { |type| type.to_s }) end register :html, :text, :js, :css, :xml, :json def self.[](type) return type if type.is_a?(self) if type.is_a?(Symbol) || types.member?(type.to_s) new(type) end end attr_reader :symbol def initialize(symbol) @symbol = symbol.to_sym end delegate :to_s, :to_sym, :to => :symbol alias to_str to_s def ref to_sym || to_s end def ==(type) return false if type.blank? symbol.to_sym == type.to_sym end end cattr_accessor :type_klass def self.delegate_to(klass) self.type_klass = klass end delegate_to Type def self.[](type) type_klass[type] end end end end
Version data entries
96 entries across 92 versions & 9 rubygems