Class: QuickAdmin::Configuration
- Inherits:
-
Object
- Object
- QuickAdmin::Configuration
- Defined in:
- lib/quick_admin/configuration.rb
Overview
Configuration class for QuickAdmin. Holds all configuration options for the admin interface.
Instance Attribute Summary collapse
-
#app_name ⇒ String
application name shown in UI (default: 'QuickAdmin').
-
#authenticate_method ⇒ Object
Returns the value of attribute authenticate_method.
-
#authentication ⇒ Symbol?
authentication method (:devise, :custom, or nil).
-
#css_framework ⇒ Symbol
CSS framework to use (:tailwind, :bootstrap, or :none).
-
#current_user_method ⇒ Symbol
method to get current user (default: :current_user).
-
#mount_path ⇒ String
URL path where admin is mounted (default: '/admin').
-
#per_page ⇒ Integer
number of records per page (default: 25).
-
#sign_out_method ⇒ Symbol
HTTP method for sign out (default: :delete).
-
#sign_out_path ⇒ String, Proc
path for sign out link (default: auto-detect).
-
#stimulus_enabled ⇒ Boolean
whether to enable Stimulus (default: true).
-
#text_editor ⇒ Symbol
text editor for rich text fields (:trix, :lexical, or :textarea).
-
#turbo_enabled ⇒ Boolean
whether to enable Turbo (default: true).
Instance Method Summary collapse
-
#bootstrap_enabled? ⇒ Boolean
Checks if Bootstrap CSS framework is enabled.
-
#devise_enabled? ⇒ Boolean
Checks if Devise authentication is enabled and available.
-
#initialize ⇒ Configuration
constructor
Initializes a new Configuration with default values.
-
#lexical_enabled? ⇒ Boolean
Checks if Lexical editor is enabled.
-
#resolved_current_user_method ⇒ Symbol
Returns the resolved current user method.
-
#resolved_sign_out_path ⇒ String?
Returns the resolved sign out path.
-
#tailwind_enabled? ⇒ Boolean
Checks if Tailwind CSS framework is enabled.
-
#trix_enabled? ⇒ Boolean
Checks if Trix editor is enabled and available.
Constructor Details
#initialize ⇒ Configuration
Initializes a new Configuration with default values.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quick_admin/configuration.rb', line 23 def initialize @authentication = nil # No authentication by default @css_framework = :none # Use built-in styles @text_editor = :textarea # Simple textarea editor @turbo_enabled = true # Turbo enabled for modern UX @stimulus_enabled = true # Stimulus enabled for controllers @per_page = 25 # Reasonable default pagination @mount_path = '/admin' # Standard admin path @app_name = 'QuickAdmin' # Default app name @sign_out_path = nil # Auto-detect from Devise or set manually @sign_out_method = :delete # Default HTTP method for sign out @current_user_method = :current_user # Method to get current user @authenticate_method = nil # Auto-detect or set manually (e.g., :authenticate_admin!) end |
Instance Attribute Details
#app_name ⇒ String
application name shown in UI (default: 'QuickAdmin')
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def app_name @app_name end |
#authenticate_method ⇒ Object
Returns the value of attribute authenticate_method.
17 18 19 |
# File 'lib/quick_admin/configuration.rb', line 17 def authenticate_method @authenticate_method end |
#authentication ⇒ Symbol?
authentication method (:devise, :custom, or nil)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def authentication @authentication end |
#css_framework ⇒ Symbol
CSS framework to use (:tailwind, :bootstrap, or :none)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def css_framework @css_framework end |
#current_user_method ⇒ Symbol
method to get current user (default: :current_user)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def current_user_method @current_user_method end |
#mount_path ⇒ String
URL path where admin is mounted (default: '/admin')
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def mount_path @mount_path end |
#per_page ⇒ Integer
number of records per page (default: 25)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def per_page @per_page end |
#sign_out_method ⇒ Symbol
HTTP method for sign out (default: :delete)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def sign_out_method @sign_out_method end |
#sign_out_path ⇒ String, Proc
path for sign out link (default: auto-detect)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def sign_out_path @sign_out_path end |
#stimulus_enabled ⇒ Boolean
whether to enable Stimulus (default: true)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def stimulus_enabled @stimulus_enabled end |
#text_editor ⇒ Symbol
text editor for rich text fields (:trix, :lexical, or :textarea)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def text_editor @text_editor end |
#turbo_enabled ⇒ Boolean
whether to enable Turbo (default: true)
16 17 18 |
# File 'lib/quick_admin/configuration.rb', line 16 def turbo_enabled @turbo_enabled end |
Instance Method Details
#bootstrap_enabled? ⇒ Boolean
Checks if Bootstrap CSS framework is enabled.
52 53 54 |
# File 'lib/quick_admin/configuration.rb', line 52 def bootstrap_enabled? css_framework == :bootstrap end |
#devise_enabled? ⇒ Boolean
Checks if Devise authentication is enabled and available.
40 41 42 |
# File 'lib/quick_admin/configuration.rb', line 40 def devise_enabled? authentication == :devise && defined?(Devise) end |
#lexical_enabled? ⇒ Boolean
Checks if Lexical editor is enabled.
64 65 66 |
# File 'lib/quick_admin/configuration.rb', line 64 def lexical_enabled? text_editor == :lexical end |
#resolved_current_user_method ⇒ Symbol
Returns the resolved current user method. Auto-detects based on available Devise models.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/quick_admin/configuration.rb', line 90 def resolved_current_user_method return current_user_method if current_user_method != :current_user # Auto-detect based on Devise models if defined?(Devise) if defined?(Admin) :current_admin else :current_user end else current_user_method end end |
#resolved_sign_out_path ⇒ String?
Returns the resolved sign out path. Auto-detects Devise path if not explicitly set.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/quick_admin/configuration.rb', line 71 def resolved_sign_out_path return sign_out_path if sign_out_path.present? # Auto-detect Devise sign out path (even if not explicitly configured) if defined?(Devise) # Check for Admin model first, then User if defined?(Admin) '/admins/sign_out' else '/users/sign_out' end else nil end end |
#tailwind_enabled? ⇒ Boolean
Checks if Tailwind CSS framework is enabled.
46 47 48 |
# File 'lib/quick_admin/configuration.rb', line 46 def tailwind_enabled? css_framework == :tailwind end |
#trix_enabled? ⇒ Boolean
Checks if Trix editor is enabled and available.
58 59 60 |
# File 'lib/quick_admin/configuration.rb', line 58 def trix_enabled? text_editor == :trix && defined?(Trix) end |