Class: RubyCms::AuthWiring
- Inherits:
-
Object
- Object
- RubyCms::AuthWiring
- Defined in:
- lib/ruby_cms/auth_wiring.rb
Overview
Wires the host app's authentication into RubyCMS:
* `include Permittable` in the User model (Permittable is copied by the core module)
* exposes `current_user` from the generated Authentication concern
The actual rails g authentication run is driven by the Installer (it needs a boot);
this unit only checks for the model and patches the generated files. Idempotent.
Constant Summary collapse
- NOTIFICATIONS_ASSOCIATION =
%( has_many :notifications, as: :recipient, dependent: :destroy, class_name: "Noticed::Notification")
Instance Method Summary collapse
-
#initialize(app_root:) ⇒ AuthWiring
constructor
A new instance of AuthWiring.
-
#patch! ⇒ Object
Patch the generated files.
- #user_model_present? ⇒ Boolean
Constructor Details
#initialize(app_root:) ⇒ AuthWiring
Returns a new instance of AuthWiring.
15 16 17 |
# File 'lib/ruby_cms/auth_wiring.rb', line 15 def initialize(app_root:) @root = Pathname.new(app_root) end |
Instance Method Details
#patch! ⇒ Object
Patch the generated files. Returns the list of files changed.
24 25 26 |
# File 'lib/ruby_cms/auth_wiring.rb', line 24 def patch! [patch_user, patch_authentication_concern].compact end |
#user_model_present? ⇒ Boolean
19 20 21 |
# File 'lib/ruby_cms/auth_wiring.rb', line 19 def user_model_present? @root.join("app/models/user.rb").exist? end |