lib/tropo-webapi-ruby/tropo-webapi-ruby-helpers.rb
##
# Transforms a single keypair into a decamelized symbol with the appropriate value. Also converts
# any timestamps to a Ruby Time object
#
# @param[String] the key to be decamelized and symobolized
# @param[Hash] the newly created hash that contins the properly formatted key
Transforms a single keypair into a decamelized symbol with the appropriate value. Also converts
any timestamps to a Ruby Time object
Transforms a single keypair into a decamelized symbol with the appropriate value . Also converts any timestamps to a Ruby Time object
def transform_pair(key, value)
        hash = { decamelize(key) => value }
        hash['timestamp'] = Time.parse(value) if hash['timestamp'] && (! hash['timestamp'].is_a?(Time))
        if hash['actions']
          if hash['actions']['name']
            key_name = hash['actions']['name']
            hash['actions'].delete('name')
            hash['actions'] = { key_name => hash['actions'] }
          end
        end
        set_session_type(hash) if hash['channel']
        hash
      end
def transform_pair ( key , value ) hash = { decamelize ( key ) => value } hash [ 'timestamp' ] = Time . parse ( value ) if hash [ 'timestamp' ] && ( ! hash [ 'timestamp' ] . is_a? ( Time ) ) if hash [ 'actions' ] if hash [ 'actions' ] [ 'name' ] key_name = hash [ 'actions' ] [ 'name' ] hash [ 'actions' ] . delete ( 'name' ) hash [ 'actions' ] = { key_name => hash [ 'actions' ] } end end set_session_type ( hash ) if hash [ 'channel' ] hash end
Transforms a single keypair into a decamelized symbol with the appropriate value.
Transforms a single keypair into a decamelized symbol with the appropriate value .
key
value
param[String]
the key to be decamelized and symobolized
the key to be decamelized and symobolized
param[Hash]
the newly created hash that contins the properly formatted key
the newly created hash that contins the properly formatted key