lib/fernet/generator.rb in fernet-2.0.rc2 vs lib/fernet/generator.rb in fernet-2.0

- old
+ new

@@ -4,18 +4,18 @@ require 'date' module Fernet # Internal: Generates Fernet tokens class Generator - # Returns the token's message + # Internal: Returns the token's message attr_accessor :message # Internal: Initializes a generator # # opts - a hash containing the following keys: - # secret: a string containing a secret, optionally Base64 encoded - # message: the message + # * secret - a string containing a secret, optionally Base64 encoded + # * message - the message def initialize(opts) @secret = opts.fetch(:secret) @message = opts[:message] @iv = opts[:iv] @now = opts[:now] @@ -23,20 +23,21 @@ # Internal: generates a secret token # # Yields itself, useful for setting or overriding the message # - # Returns the token as a string - # # Examples - # generator = Generator.new(secret: some_secret) - # token = generator.generate do |g| - # g.message = 'this is my message' - # end # - # generator = Generator.new(secret: some_secret, - # message: 'this is my message') - # token = generator.generate + # generator = Generator.new(secret: some_secret) + # token = generator.generate do |g| + # g.message = 'this is my message' + # end + # + # generator = Generator.new(secret: some_secret, + # message: 'this is my message') + # token = generator.generate + # + # Returns the token as a string def generate yield self if block_given? token = Token.generate(secret: @secret, message: @message,