aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_text/engine.rb
blob: c11bb7cce9f943d13d27728a48fec1826a19c2c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "rails/engine"

module ActiveText
  class Engine < Rails::Engine
    isolate_namespace ActiveText
    config.eager_load_namespaces << ActiveText

    initializer "active_text.attribute" do
      ActiveSupport.on_load(:active_record) do
        include ActiveText::Attribute
      end
    end

    initializer "active_text.active_storage_extension" do
      require "active_storage/blob"

      class ActiveStorage::Blob
        include ActiveText::Attachable

        def previewable_attachable?
          representable?
        end
      end
    end

    initializer "active_text.helper" do
      ActiveSupport.on_load(:action_controller_base) do
        helper ActiveText::TagHelper
      end
    end

    initializer "active_text.config" do
      config.after_initialize do |app|
        ActiveText.renderer ||= ApplicationController.renderer
      end
    end
  end
end