Class: LeveretAuth::Config::Builder
- Inherits:
-
Object
- Object
- LeveretAuth::Config::Builder
- Defined in:
- lib/leveret_auth/config.rb
Overview
Default DiviseAuth configuration builder
Instance Method Summary collapse
- #add_provider(name, **opts) ⇒ Object
- #before_user_save(&block) ⇒ Object
- #build ⇒ Object
- #devise_for(model_name) ⇒ Object
-
#initialize(config = Config.new, &block) ⇒ Builder
constructor
A new instance of Builder.
- #validate ⇒ Object
Constructor Details
Instance Method Details
#add_provider(name, **opts) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/leveret_auth/config.rb', line 79 def add_provider(name, **opts) opts = Utils.load_json_file(opts[:file_path]) if opts[:file_path] begin klass = Strategies.const_get("#{name.to_s.camelize}Strategy") rescue NameError raise LoadError, "Could not find matching strategy for #{name}." end @config.providers << name.downcase klass.configure(opts.compact) end |
#before_user_save(&block) ⇒ Object
75 76 77 |
# File 'lib/leveret_auth/config.rb', line 75 def before_user_save(&block) @config.instance_variable_set(:@before_user_save, block) if block_given? end |
#build ⇒ Object
64 65 66 67 |
# File 'lib/leveret_auth/config.rb', line 64 def build validate @config end |
#devise_for(model_name) ⇒ Object
71 72 73 |
# File 'lib/leveret_auth/config.rb', line 71 def devise_for(model_name) @config.instance_variable_set(:@user_model_name, model_name) end |
#validate ⇒ Object
69 |
# File 'lib/leveret_auth/config.rb', line 69 def validate; end |