Class: BarkestCore::UtcConversion::UtcConverter
- Inherits:
-
ActiveRecord::Type::Value
- Object
- ActiveRecord::Type::Value
- BarkestCore::UtcConversion::UtcConverter
- Includes:
- ActiveRecord::Type::Decorator
- Defined in:
- lib/barkest_core/concerns/utc_conversion.rb
Instance Method Summary collapse
- #convert_to_utc(value) ⇒ Object
- #type_cast_from_database(value) ⇒ Object
- #type_cast_from_user(value) ⇒ Object
Instance Method Details
#convert_to_utc(value) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/barkest_core/concerns/utc_conversion.rb', line 16 def convert_to_utc(value) if value.is_a?(Array) value.map { |v| convert_to_utc(v) } else Time.utc_parse(value) rescue nil end end |
#type_cast_from_database(value) ⇒ Object
8 9 10 |
# File 'lib/barkest_core/concerns/utc_conversion.rb', line 8 def type_cast_from_database(value) convert_to_utc(value) end |
#type_cast_from_user(value) ⇒ Object
12 13 14 |
# File 'lib/barkest_core/concerns/utc_conversion.rb', line 12 def type_cast_from_user(value) convert_to_utc(value) end |