Module: Devision::Models::Tokenizable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devision/models/tokenizable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_fields(klass) ⇒ Object

Fields required on the target Model



7
8
9
# File 'lib/devision/models/tokenizable.rb', line 7

def self.required_fields(klass)
  [:token]
end

Instance Method Details

#clear_tokenObject



25
26
27
28
# File 'lib/devision/models/tokenizable.rb', line 25

def clear_token
  @raw_token = nil
  self.token = nil
end

#generate_tokensObject



15
16
17
18
19
# File 'lib/devision/models/tokenizable.rb', line 15

def generate_tokens
  raw, enc = Devision.token_generator.generate(self.class, :token)
  @raw_token = raw
  self.token = enc
end

#generate_tokens!Object



21
22
23
# File 'lib/devision/models/tokenizable.rb', line 21

def generate_tokens!
  generate_tokens && save(validate: false)
end