lib/secretkey.rb in secretkey-1.1.0 vs lib/secretkey.rb in secretkey-1.1.1
- old
+ new
@@ -1,29 +1,19 @@
require 'digest'
module SecretKey
class SecretKey
+ attr_reader :key, :secret, :timestamp
- def initialize(key, secret, options={})
+ def initialize(key, secret, timestamp: Time.now.to_i)
+ raise ArgumentError, 'Time Stamp is not a valid integer.' unless timestamp.is_a? Integer
+
@key = key
@secret = secret
- @options = options
-
- extract_options!
+ @timestamp = timestamp
end
def token
- raise ArgumentError, 'Time Stamp is not a valid integer.' unless @timestamp.is_a? Integer
- Digest::SHA1.hexdigest("#{@key}:#{@secret}:#{@timestamp}")
+ Digest::SHA1.hexdigest("#{key}:#{secret}:#{timestamp}")
end
-
- def timestamp
- @timestamp ||= Time.now.to_i
- end
-
- private
-
- def extract_options!
- @timestamp = @options.fetch(:timestamp, timestamp)
- end
end
-end
\ No newline at end of file
+end