Class: ViewSpec::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/view_spec/type.rb

Constant Summary collapse

TYPES =
i[boolean date date_time decimal float integer string symbol time]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Type

Returns a new instance of Type.



7
8
9
# File 'lib/view_spec/type.rb', line 7

def initialize(**options)
  @options = options
end

Class Method Details

.for(type) ⇒ Object



16
17
18
19
20
# File 'lib/view_spec/type.rb', line 16

def for(type, ...)
  return new(...) unless type.in?(TYPES)

  "ViewSpec::Types::#{type.to_s.camelize}".constantize.new(...)
end

Instance Method Details

#typeObject



11
12
13
# File 'lib/view_spec/type.rb', line 11

def type
  self.class.name.demodulize.to_sym
end