class FunWithJsonApi::Attributes::DateAttribute
Constants
- DATE_FORMAT
Public Instance Methods
decode(value)
click to toggle source
# File lib/fun_with_json_api/attributes/date_attribute.rb, line 6 def decode(value) Date.strptime(value, DATE_FORMAT) if value rescue ArgumentError => exception raise build_invalid_attribute_error(exception, value) end
Private Instance Methods
build_invalid_attribute_error(exception, value)
click to toggle source
# File lib/fun_with_json_api/attributes/date_attribute.rb, line 14 def build_invalid_attribute_error(exception, value) payload = ExceptionPayload.new payload.detail = I18n.t('fun_with_json_api.exceptions.invalid_date_attribute') payload.pointer = "/data/attributes/#{name}" Exceptions::InvalidAttribute.new(exception.message + ": #{value.inspect}", payload) end