Class: Blueprinter::DateTimeFormatter
- Inherits:
-
Object
- Object
- Blueprinter::DateTimeFormatter
- Defined in:
- lib/blueprinter/formatters/date_time_formatter.rb
Constant Summary collapse
- InvalidDateTimeFormatterError =
Class.new(BlueprinterError)
Instance Method Summary collapse
Instance Method Details
#format(value, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/blueprinter/formatters/date_time_formatter.rb', line 5 def format(value, ) return value if value.nil? field_format = [:datetime_format] if value.respond_to?(:strftime) value = format_datetime(value, field_format) elsif field_format raise InvalidDateTimeFormatterError, 'Cannot format invalid DateTime object' end value end |