Class: LookerSDK::Client::Serializer

Inherits:
Sawyer::Serializer
  • Object
show all
Defined in:
lib/looker-sdk/client.rb

Instance Method Summary collapse

Instance Method Details

#decode_hash_value(key, value) ⇒ Object

slight modification to the base class’ decode_hash_value function to less permissive when decoding time values. also prevent conversion from non-string types to Time e.g. integer/float timestamp

See github.com/looker/looker-sdk-ruby/issues/53 for more details

Base class function that we’re overriding: github.com/lostisland/sawyer/blob/master/lib/sawyer/serializer.rb#L101-L121



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/looker-sdk/client.rb', line 397

def decode_hash_value(key, value)
  if time_field?(key, value)
    if value.is_a?(String)
      begin
        Time.iso8601(value)
      rescue ArgumentError
        value
      end
    else
      value
    end
  else
    super
  end
end

#encode(data) ⇒ Object



386
387
388
# File 'lib/looker-sdk/client.rb', line 386

def encode(data)
  data.kind_of?(Faraday::UploadIO) ? data : super
end