Class: InquiryAttrs::Installer
- Inherits:
-
Object
- Object
- InquiryAttrs::Installer
- Defined in:
- lib/inquiry_attrs/installer.rb
Overview
Manages the lifecycle of the inquiry_attrs initializer inside a Rails app.
This class holds all file-system logic so it can be unit-tested without requiring a full Rails boot or Rake DSL. The rake tasks are thin shells that delegate here.
Constant Summary collapse
- INITIALIZER_PATH =
Pathname.new('config/initializers/inquiry_attrs.rb')
- INITIALIZER_CONTENT =
<<~RUBY # frozen_string_literal: true # Auto-include InquiryAttrs::Concern into every ActiveRecord model so that # the .inquirer macro is available without an explicit include in each class. # # Generated by: rails inquiry_attrs:install # # To opt out of auto-include, remove this file and add # include InquiryAttrs::Concern # to whichever models need it. ActiveSupport.on_load(:active_record) do include InquiryAttrs::Concern end RUBY
Class Method Summary collapse
-
.install!(rails_root) ⇒ :created, :skipped
Write the initializer to
rails_root/config/initializers/inquiry_attrs.rb. -
.uninstall!(rails_root) ⇒ :removed, :skipped
Remove the initializer if it exists.
Class Method Details
.install!(rails_root) ⇒ :created, :skipped
Write the initializer to rails_root/config/initializers/inquiry_attrs.rb.
37 38 39 40 41 42 43 44 |
# File 'lib/inquiry_attrs/installer.rb', line 37 def self.install!(rails_root) destination = Pathname.new(rails_root).join(INITIALIZER_PATH) return :skipped if destination.exist? destination.write(INITIALIZER_CONTENT) :created end |
.uninstall!(rails_root) ⇒ :removed, :skipped
Remove the initializer if it exists.
50 51 52 53 54 55 56 57 |
# File 'lib/inquiry_attrs/installer.rb', line 50 def self.uninstall!(rails_root) destination = Pathname.new(rails_root).join(INITIALIZER_PATH) return :skipped unless destination.exist? destination.delete :removed end |