Method: Devise::Models.config

Defined in:
lib/devise/models.rb

.config(mod, *accessors) ⇒ Object

Creates configuration values for Devise and for the given module.

Devise::Models.config(Devise::Authenticable, :stretches, 10)

The line above creates:

1) An accessor called Devise.stretches, which value is used by default;

2) Some class methods for your model Model.stretches and Model.stretches=
   which have higher priority than Devise.stretches;

3) And an instance method stretches.

To add the class methods you need to have a module ClassMethods defined inside the given class.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/devise/models.rb', line 30

def self.config(mod, *accessors) #:nodoc:
  accessors.each do |accessor|
    mod.class_eval "      def \#{accessor}\n        if defined?(@\#{accessor})\n          @\#{accessor}\n        elsif superclass.respond_to?(:\#{accessor})\n          superclass.\#{accessor}\n        else\n          Devise.\#{accessor}\n        end\n      end\n\n      def \#{accessor}=(value)\n        @\#{accessor} = value\n      end\n    METHOD\n  end\nend\n", __FILE__, __LINE__ + 1