ads_common/lib/ads_common/credential_handler.rb
def credentials=(new_credentials)
      # Find new and changed properties.
      diff = new_credentials.inject([]) do |result, (key, value)|
        result << [key, value] if value != @credentials[key]
        result
      end

      # Find removed properties.
      diff = @credentials.inject(diff) do |result, (key, _)|
        result << [key, nil] unless new_credentials.include?(key)
        result
      end

      # Set each property.
      diff.each { |entry| set_credential(entry[0], entry[1]) }

      return nil
    end
def credentials=(new_credentials)
      # Find new and changed properties.
      diff = new_credentials.inject([]) do |result, (key, value)|
        result << [key, value] if value != @credentials[key]
        result
      end

      # Find removed properties.
      diff = @credentials.inject(diff) do |result, (key, _)|
        result << [key, nil] unless new_credentials.include?(key)
        result
      end

      # Set each property.
      diff.each { |entry| set_credential(entry[0], entry[1]) }

      return nil
    end
def credentials = ( new_credentials ) # Find new and changed properties. diff = new_credentials . inject ( [ ] ) do | result , ( key , value ) | result << [ key , value ] if value != @credentials [ key ] result end # Find removed properties. diff = @credentials . inject ( diff ) do | result , ( key , _ ) | result << [ key , nil ] unless new_credentials . include? ( key ) result end # Set each property. diff . each { | entry | set_credential ( entry [ 0 ] , entry [ 1 ] ) } return nil end
Set the credentials hash to a new one. Calculate difference, and call the
 AuthHandler callback appropriately.
Set the credentials hash to a new one . Calculate difference and call the AuthHandler callback appropriately .