class IknowParams::Serializer::Nullable
Serialize a potentially nil application type to JSON types. Does not support fully rendering to/from a string.
Attributes
serializer[R]
Public Class Methods
new(serializer)
click to toggle source
# File lib/iknow_params/serializer/nullable.rb, line 32 def initialize(serializer) @serializer = serializer end
Public Instance Methods
dump(val, json: false)
click to toggle source
# File lib/iknow_params/serializer/nullable.rb, line 16 def dump(val, json: false) if val.nil? nil else serializer.dump(val, json: json) end end
json_value?()
click to toggle source
# File lib/iknow_params/serializer/nullable.rb, line 28 def json_value? true end
load(val)
click to toggle source
# File lib/iknow_params/serializer/nullable.rb, line 8 def load(val) if val.nil? nil else serializer.load(val) end end
matches_type?(val)
click to toggle source
Calls superclass method
IknowParams::Serializer#matches_type?
# File lib/iknow_params/serializer/nullable.rb, line 24 def matches_type?(val) val.nil? || super end