Sha256: c59c1fb7b8aa8aaa5c1ce4bf1f0916acc07e855e43ae7a161c03fd4ede928cf6

Contents?: true

Size: 809 Bytes

Versions: 13

Compression:

Stored size: 809 Bytes

Contents

module Twilio
  def self.serialize_iso8601(date)
    if date
      date.iso8601
    end
  end

  def self.deserialize_rfc2822(date)
    unless date.nil?
      Time.rfc2822(date)
    end
  end

  def self.deserialize_iso8601(date)
    unless date.nil?
      Time.parse(date)
    end
  end

  def self.flatten(map, result={}, previous=[])
    map.each do |key, value|
      if value.is_a? Hash
        self.flatten(value, result, previous + [key])
      else
        result[(previous + [key]).join('.')] = value
      end
    end

    result
  end

  def self.prefixed_collapsible_map(map, prefix)
    result = {}
    if map.is_a? Hash
      flattened = self.flatten(map)
      result = {}
      flattened.each do |key, value|
        result[prefix + '.' + key] = value
      end
    end

    result
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
twilio-ruby-5.0.0.rc19 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc18 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc17 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc16 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc15 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc14 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc13 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc12 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc11 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc10 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc9 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc8 lib/twilio-ruby/framework/serialize.rb
twilio-ruby-5.0.0.rc7 lib/twilio-ruby/framework/serialize.rb