Sha256: a78af10ddd867375df48516c3c48fc57673e3a3a81a49dd7eb51f9b2a78a4b6b
Contents?: true
Size: 584 Bytes
Versions: 1
Compression:
Stored size: 584 Bytes
Contents
require 'faker' module JSONAPIonify::Types class TimeStringType < BaseType def load(value) Time.parse value end def dump(value) case value when Time JSON.load JSON.dump(value.to_time) else raise TypeError, "#{value} is not a valid JSON #{name}." end end def sample(field_name) field_name = field_name.to_s if field_name.to_s.end_with?('ed_at') || field_name.include?('start') Faker::Time.backward elsif field_name.include?('end') Faker::Time.forward end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsonapionify-0.9.0 | lib/jsonapionify/types/time_string_type.rb |