Class: Decko::Application

Inherits:
Rails::Application
  • Object
show all
Defined in:
decko/lib/decko/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(base) ⇒ Object



19
20
21
22
23
24
# File 'decko/lib/decko/application.rb', line 19

def inherited base
  super
  Rails.app_class = base
  add_lib_to_load_path!(find_root(base.called_from))
  ActiveSupport.run_load_hooks(:before_configuration, base.instance)
end

Instance Method Details

#add_path(paths, path, options = {}) ⇒ Object



27
28
29
30
31
# File 'decko/lib/decko/application.rb', line 27

def add_path paths, path, options={}
  root = options.delete(:root) || Decko.gem_root
  options[:with] = File.join(root, (options[:with] || path))
  paths.add path, options
end

#configObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'decko/lib/decko/application.rb', line 33

def config
  @config ||= begin
    config = super

    Cardio.set_config config

    # any config settings below:
    # (a) do not apply to Card used outside of a Decko context
    # (b) cannot be overridden in a deck's application.rb, but
    # (c) CAN be overridden in an environment file

    # therefore, in general, they should be restricted to settings that
    # (1) are specific to the web environment, and
    # (2) should not be overridden
    # ..and we should address (c) above!

    # general card settings (overridable and not) should be in cardio.rb
    # overridable decko-specific settings don't have a place yet
    # but should probably follow the cardio pattern.

    # config.load_defaults "6.0"
    config.autoloader = :zeitwerk
    config.load_default = "6.0"
    config.i18n.enforce_available_locales = true
    # config.active_record.raise_in_transactional_callbacks = true

    config.allow_concurrency = false
    config.assets.enabled = false
    config.assets.version = "1.0"

    config.filter_parameters += [:password]

    # Rails.autoloaders.log!
    Rails.autoloaders.main.ignore(
      File.join(Cardio.gem_root, "lib/card/seed_consts.rb")
    )
    config
  end
end

#pathsObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'decko/lib/decko/application.rb', line 73

def paths
  @paths ||= begin
    paths = super
    Cardio.set_paths paths

    paths.add "files"

    paths["app/models"] = []
    paths["app/mailers"] = []
    paths["app/controllers"] = []

    unless paths["config/routes.rb"].existent.present?
      add_path paths, "config/routes.rb",
               with: "rails/application-routes.rb"
    end

    paths
  end
end