lib/token_master/model.rb in token_master-1.0.1 vs lib/token_master/model.rb in token_master-1.1.0

- old
+ new

@@ -22,10 +22,15 @@ # Defines a method on the tokenable model instance to send tokenable action instructions, e.g., `user.send_confim_instructions!`. Accepts a block with app logic to send instructions. define_method("send_#{tokenable}_instructions!") do |&email| TokenMaster::Core.send_instructions!(self, tokenable, &email) end + # Defines a method on the tokenable model instance to generate a new token and send tokenable action instructions again, e.g., `user.resend_confim_instructions!`. Accepts a block with app logic to send instructions. + define_method("resend_#{tokenable}_instructions!") do |&email| + TokenMaster::Core.resend_instructions!(self, tokenable, &email) + end + # Defines a method on the tokenable model instance to retrieve the status of a tokenable action, e.g., `user.confim_status` define_method("#{tokenable}_status") do TokenMaster::Core.status(self, tokenable) end @@ -33,10 +38,10 @@ define_method("force_#{tokenable}!") do |**params| TokenMaster::Core.force_tokenable!(self, tokenable, **params) end # class methods - # Defines a method on the tokenable model class to completed a tokenable action given a token, e.g., `User.confim_by_token!`. Takes the token and accepts any keyword arguments for `required_params`. + # Defines a method on the tokenable model class to complete a tokenable action given a token, e.g., `User.confim_by_token!`. Takes the token and accepts any keyword arguments for `required_params`. define_singleton_method("#{tokenable}_by_token!") do |token, **params| TokenMaster::Core.do_by_token!(self, tokenable, token, **params) end end end