Class: TokenizeAttr::Tokenizer Private
- Inherits:
-
Object
- Object
- TokenizeAttr::Tokenizer
- Defined in:
- lib/tokenize_attr/tokenizer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal class that holds all token-generation logic.
Keeping this logic here — rather than inside +TokenizeAttr::Concern+'s
class_methods block — ensures that none of these methods are mixed
into the including model class, eliminating any risk of method-name
collisions on user models.
Class Method Summary collapse
-
.apply(klass, attribute, generator:, size:, prefix:, retries:) ⇒ Object
private
Determines which generation strategy to use and configures
klass.
Class Method Details
.apply(klass, attribute, generator:, size:, prefix:, retries:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines which generation strategy to use and configures klass.
Routes to has_secure_token when all of the following are true:
generatorisnilprefixisnilklassresponds tohas_secure_token(Rails 5+)
Otherwise installs a custom before_create callback.
33 34 35 36 37 38 39 40 |
# File 'lib/tokenize_attr/tokenizer.rb', line 33 def apply(klass, attribute, generator:, size:, prefix:, retries:) # rubocop:disable Metrics/ParameterLists if generator.nil? && prefix.nil? && has_secure_token?(klass) via_has_secure_token(klass, attribute, size) else via_callback(klass, attribute, size: size, prefix: prefix, retries: retries, generator: generator) end end |