Class: ActionView::Template::Types::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/template/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Type

Returns a new instance of Type.



27
28
29
# File 'lib/action_view/template/types.rb', line 27

def initialize(symbol)
  @symbol = symbol.to_sym
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



25
26
27
# File 'lib/action_view/template/types.rb', line 25

def symbol
  @symbol
end

Class Method Details

.[](type) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/action_view/template/types.rb', line 17

def self.[](type)
  return type if type.is_a?(self)

  if type.is_a?(Symbol) || types.member?(type.to_s)
    new(type)
  end
end

.register(*t) ⇒ Object



11
12
13
# File 'lib/action_view/template/types.rb', line 11

def self.register(*t)
  types.merge(t.map { |type| type.to_s })
end

Instance Method Details

#==(type) ⇒ Object



38
39
40
41
# File 'lib/action_view/template/types.rb', line 38

def ==(type)
  return false if type.blank?
  symbol.to_sym == type.to_sym
end

#refObject



34
35
36
# File 'lib/action_view/template/types.rb', line 34

def ref
  to_sym || to_s
end