Class: Solidcrud::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/solidcrud/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
27
# File 'lib/solidcrud/configuration.rb', line 19

def initialize
  @models_exclude = []
  @authenticate_method = nil
  @basic_auth_username = nil
  @basic_auth_password = nil
  @auth_type = :custom # Default to custom authentication
  @jwt_secret = nil
  @devise_scope = :user
end

Instance Attribute Details

#auth_typeObject

Returns the value of attribute auth_type.



15
16
17
# File 'lib/solidcrud/configuration.rb', line 15

def auth_type
  @auth_type
end

#authenticate_methodObject

Returns the value of attribute authenticate_method.



13
14
15
# File 'lib/solidcrud/configuration.rb', line 13

def authenticate_method
  @authenticate_method
end

#basic_auth_passwordObject

Returns the value of attribute basic_auth_password.



14
15
16
# File 'lib/solidcrud/configuration.rb', line 14

def basic_auth_password
  @basic_auth_password
end

#basic_auth_usernameObject

Returns the value of attribute basic_auth_username.



14
15
16
# File 'lib/solidcrud/configuration.rb', line 14

def basic_auth_username
  @basic_auth_username
end

#devise_scopeObject

Returns the value of attribute devise_scope.



17
18
19
# File 'lib/solidcrud/configuration.rb', line 17

def devise_scope
  @devise_scope
end

#jwt_secretObject

Returns the value of attribute jwt_secret.



16
17
18
# File 'lib/solidcrud/configuration.rb', line 16

def jwt_secret
  @jwt_secret
end

#models_excludeObject

Returns the value of attribute models_exclude.



12
13
14
# File 'lib/solidcrud/configuration.rb', line 12

def models_exclude
  @models_exclude
end

Instance Method Details

#authenticate_with(&block) ⇒ Object



41
42
43
# File 'lib/solidcrud/configuration.rb', line 41

def authenticate_with(&block)
  @authenticate_method = block
end

#basic_auth_enabled?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/solidcrud/configuration.rb', line 29

def basic_auth_enabled?
  @basic_auth_username.present? && @basic_auth_password.present?
end

#devise_enabled?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/solidcrud/configuration.rb', line 37

def devise_enabled?
  @auth_type == :devise
end

#jwt_enabled?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/solidcrud/configuration.rb', line 33

def jwt_enabled?
  @jwt_secret.present?
end

#use_basic_authObject

Authentication type setters



46
47
48
# File 'lib/solidcrud/configuration.rb', line 46

def use_basic_auth
  @auth_type = :basic_auth
end

#use_custom(&block) ⇒ Object



59
60
61
62
# File 'lib/solidcrud/configuration.rb', line 59

def use_custom(&block)
  @auth_type = :custom
  @authenticate_method = block
end

#use_devise(scope: :user) ⇒ Object



50
51
52
53
# File 'lib/solidcrud/configuration.rb', line 50

def use_devise(scope: :user)
  @auth_type = :devise
  @devise_scope = scope
end

#use_jwtObject



55
56
57
# File 'lib/solidcrud/configuration.rb', line 55

def use_jwt
  @auth_type = :jwt
end