Class: Typero::TimezoneType

Inherits:
Type
  • Object
show all
Defined in:
lib/typero/type/types/timezone_type.rb

Constant Summary

Constants inherited from Type

Typero::Type::ERRORS, Typero::Type::OPTS, Typero::Type::OPTS_KEYS

Instance Attribute Summary

Attributes inherited from Type

#opts

Instance Method Summary collapse

Methods inherited from Type

allowed_opt?, #db_field, db_schema, #default, error, #get, #initialize, load, opts, #value

Constructor Details

This class inherits a constructor from Typero::Type

Instance Method Details

#db_schemaObject



10
11
12
# File 'lib/typero/type/types/timezone_type.rb', line 10

def db_schema
  [:string, { length: 50 }]
end

#setObject



4
5
6
7
8
# File 'lib/typero/type/types/timezone_type.rb', line 4

def set
  TZInfo::Timezone.get(value)
rescue TZInfo::InvalidTimezoneIdentifier
  error_for :invalid_time_zone
end