lib/ably/rest/client.rb in ably-0.7.2 vs lib/ably/rest/client.rb in ably-0.7.4

- old
+ new

@@ -65,11 +65,11 @@ # @api private attr_reader :options # Creates a {Ably::Rest::Client Rest Client} and configures the {Ably::Auth} object for the connection. # - # @param [Hash,String] options an options Hash used to configure the client and the authentication, or String with an API key + # @param [Hash,String] options an options Hash used to configure the client and the authentication, or String with an API key or Token ID # @option options (see Ably::Auth#authorise) # @option options [Boolean] :tls TLS is used by default, providing a value of false disables TLS. Please note Basic Auth is disallowed without TLS as secrets cannot be transmitted over unsecured connections. # @option options [String] :api_key API key comprising the key ID and key secret in a single string # @option options [Boolean] :use_token_auth Will force Basic Auth if set to false, and TOken auth if set to true # @option options [String] :environment Specify 'sandbox' when testing the client library against an alternate Ably environment @@ -94,10 +94,14 @@ def initialize(options, &token_request_block) raise ArgumentError, 'Options Hash is expected' if options.nil? options = options.clone if options.kind_of?(String) - options = { api_key: options } + options = if options.match(/^[\w]{2,}\.[\w]{2,}:[\w]{2,}$/) + { api_key: options } + else + { token_id: options } + end end @tls = options.delete(:tls) == false ? false : true @environment = options.delete(:environment) # nil is production @protocol = options.delete(:protocol) || :msgpack