Class: IknowParams::Serializer::Timezone
- Inherits:
-
IknowParams::Serializer
- Object
- IknowParams::Serializer
- IknowParams::Serializer::Timezone
- Defined in:
- lib/iknow_params/serializer.rb
Instance Attribute Summary
Attributes inherited from IknowParams::Serializer
Instance Method Summary collapse
- #dump(val, json: nil) ⇒ Object
-
#initialize ⇒ Timezone
constructor
A new instance of Timezone.
- #load(str) ⇒ Object
Methods inherited from IknowParams::Serializer
for, for!, json_value?, #matches_type!, #matches_type?, singleton
Constructor Details
#initialize ⇒ Timezone
Returns a new instance of Timezone.
213 214 215 |
# File 'lib/iknow_params/serializer.rb', line 213 def initialize super(::TZInfo::Timezone) end |
Instance Method Details
#dump(val, json: nil) ⇒ Object
223 224 225 226 |
# File 'lib/iknow_params/serializer.rb', line 223 def dump(val, json: nil) matches_type!(val) val.identifier end |
#load(str) ⇒ Object
217 218 219 220 221 |
# File 'lib/iknow_params/serializer.rb', line 217 def load(str) TZInfo::Timezone.get(str) rescue TZInfo::InvalidTimezoneIdentifier => _e raise LoadError.new("Invalid identifier for TZInfo zone: #{str}") end |