-
Notifications
You must be signed in to change notification settings - Fork 21.4k
/
types.rb
50 lines (40 loc) · 1008 Bytes
/
types.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require "active_support/core_ext/module/attribute_accessors"
module ActionView
class Template # :nodoc:
# SimpleType is mostly just a stub implementation for when Action View
# is used without Action Dispatch.
class SimpleType # :nodoc:
@symbols = [ :html, :text, :js, :css, :xml, :json ]
class << self
attr_reader :symbols
def [](type)
if type.is_a?(self)
type
else
new(type)
end
end
def valid_symbols?(symbols) # :nodoc
symbols.all? { |s| @symbols.include?(s) }
end
end
attr_reader :symbol
def initialize(symbol)
@symbol = symbol.to_sym
end
def to_s
@symbol.to_s
end
alias to_str to_s
def ref
@symbol
end
alias to_sym ref
def ==(type)
@symbol == type.to_sym unless type.blank?
end
end
Types = SimpleType # :nodoc:
end
end