Module: Sorcery::Model

Included in:
Sorcery
Defined in:
lib/sorcery/model.rb,
lib/sorcery.rb,
lib/sorcery/model/config.rb,
lib/sorcery/model/temporary_token.rb,
lib/sorcery/model/submodules/external.rb,
lib/sorcery/model/submodules/remember_me.rb,
lib/sorcery/model/submodules/reset_password.rb,
lib/sorcery/model/submodules/user_activation.rb,
lib/sorcery/model/submodules/activity_logging.rb,
lib/sorcery/model/submodules/brute_force_protection.rb

Overview

This module handles all plugin operations which are related to the Model layer in the MVC pattern. It should be included into the ORM base class. In the case of Rails this is usually ActiveRecord (actually, in that case, the plugin does this automatically).

When included it defines a single method: 'authenticates_with_sorcery!' which when called adds the other capabilities to the class. This method is also the place to configure the plugin in the Model layer.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods, Submodules, TemporaryToken Classes: Config

Instance Method Summary collapse

Instance Method Details

#authenticates_with_sorcery!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sorcery/model.rb', line 10

def authenticates_with_sorcery!
  @sorcery_config = Config.new

  extend ClassMethods # included here, before submodules, so they can be overriden by them.
  include InstanceMethods
  include TemporaryToken

  include_required_submodules!

  # This runs the options block set in the initializer on the model class.
  ::Sorcery::Controller::Config.user_config.tap{|blk| blk.call(@sorcery_config) if blk}

  define_base_fields
  init_orm_hooks!

  @sorcery_config.after_config << :add_config_inheritance if @sorcery_config.subclasses_inherit_config
  @sorcery_config.after_config.each { |c| send(c) }
end