brick 1.0.73 → 1.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31f69b5035fcebf947e729c3ebabdf3a686c364fb9ddc6a764a2b34740fdb7c9
4
- data.tar.gz: 87009aad044a5a110146d26dc02f62451b18e7ad67b2b07d420edff0718a18c6
3
+ metadata.gz: acd5fdf68935981a46106c879f5ac1fb44ac790c269c3eb2c5429cd67880f916
4
+ data.tar.gz: 260ce60eeaf2e4b17ca5b5e76e54960c4d2685c9cb9d8549a35a16ce49b5a36c
5
5
  SHA512:
6
- metadata.gz: 300fe830280b2ad9d265fa62166aac01ba3e511090f95efa412d1b9ed42fbd72b9f17f8fe51ac1bb358be42f012b46cffbb3c142f6fd3b11f2a442025824e8ec
7
- data.tar.gz: abbd021f67adb2c03aae76340ba1cb1f38d0be5b5774d11c5a01a1315e02b80c293c9008021915315416da28937b40af59d821e41ad6ac0eed890be162865d98
6
+ metadata.gz: 00f45ff020fcd729c2115f6d9f6ab0ab588247b2d727de7e1bd6acf53fa685ef76eeecce181a7a0c4659d8156971f88466915749cfad44e993993179435acdbd
7
+ data.tar.gz: 74f0b40c44bae3729624ca0ba6a378f9067e4b0aa98460a03aa193e292432576327991d8c2a107317d8ce51ce223eee780a0d632d5805ca14b91a1b55388259f
@@ -235,7 +235,7 @@ module ActiveRecord
235
235
 
236
236
  def self.bt_link(assoc_name)
237
237
  assoc_name = CGI.escapeHTML(assoc_name.to_s)
238
- model_path = Rails.application.routes.url_helpers.send("#{_brick_index}_path".to_sym)
238
+ model_path = ::Rails.application.routes.url_helpers.send("#{_brick_index}_path".to_sym)
239
239
  av_class = Class.new.extend(ActionView::Helpers::UrlHelper)
240
240
  av_class.extend(ActionView::Helpers::TagHelper) if ActionView.version < ::Gem::Version.new('7')
241
241
  link = av_class.link_to(name, model_path)
@@ -641,7 +641,7 @@ JOIN (SELECT #{selects.join(', ')}, COUNT(#{'DISTINCT ' if hm.options[:through]}
641
641
  module_prefixes.unshift('') unless module_prefixes.first.blank?
642
642
  module_name = module_prefixes[0..-2].join('::')
643
643
  if (snp = ::Brick.config.sti_namespace_prefixes)&.key?("::#{module_name}::") || snp&.key?("#{module_name}::") ||
644
- File.exist?(candidate_file = Rails.root.join('app/models' + module_prefixes.map(&:underscore).join('/') + '.rb'))
644
+ File.exist?(candidate_file = ::Rails.root.join('app/models' + module_prefixes.map(&:underscore).join('/') + '.rb'))
645
645
  _brick_find_sti_class(type_name) # Find this STI class normally
646
646
  else
647
647
  # Build missing prefix modules if they don't yet exist
@@ -710,13 +710,17 @@ end
710
710
  Module.class_exec do
711
711
  alias _brick_const_missing const_missing
712
712
  def const_missing(*args)
713
- if (self.const_defined?(args.first) && (possible = self.const_get(args.first)) && possible != self) ||
714
- (self != Object && Object.const_defined?(args.first) &&
715
- (
716
- (possible = Object.const_get(args.first)) &&
717
- (possible != self || (possible == self && possible.is_a?(Class)))
718
- )
719
- )
713
+ desired_classname = (self == Object) ? args.first.to_s : "#{name}::#{args.first}"
714
+ if ((is_defined = self.const_defined?(args.first)) && (possible = self.const_get(args.first)) && possible.name == desired_classname) ||
715
+ # Try to require the respective Ruby file
716
+ ((filename = ActiveSupport::Dependencies.search_for_file(desired_classname.underscore) ||
717
+ (self != Object && ActiveSupport::Dependencies.search_for_file((desired_classname = args.first.to_s).underscore))
718
+ ) && (require_dependency(filename) || true) &&
719
+ ((possible = self.const_get(args.first)) && possible.name == desired_classname)
720
+ ) ||
721
+ # If any class has turned up so far (and we're not in the middle of eager loading)
722
+ # then return what we've found.
723
+ (is_defined && !::Brick.is_eager_loading)
720
724
  return possible
721
725
  end
722
726
  class_name = ::Brick.namify(args.first.to_s)
@@ -766,7 +770,7 @@ Module.class_exec do
766
770
  (schema_name = [(singular_table_name = class_name.underscore),
767
771
  (table_name = singular_table_name.pluralize),
768
772
  ::Brick.is_oracle ? class_name.upcase : class_name,
769
- (plural_class_name = class_name.pluralize)].find { |s| Brick.db_schemas.include?(s) }&.camelize ||
773
+ (plural_class_name = class_name.pluralize)].find { |s| Brick.db_schemas&.include?(s) }&.camelize ||
770
774
  (::Brick.config.sti_namespace_prefixes&.key?("::#{class_name}::") && class_name))
771
775
  return self.const_get(schema_name) if self.const_defined?(schema_name)
772
776
 
@@ -789,7 +793,7 @@ Module.class_exec do
789
793
  # module_prefixes = type_name.split('::')
790
794
  # path = base_module.name.split('::')[0..-2] + []
791
795
  # module_prefixes.unshift('') unless module_prefixes.first.blank?
792
- # candidate_file = Rails.root.join('app/models' + module_prefixes.map(&:underscore).join('/') + '.rb')
796
+ # candidate_file = ::Rails.root.join('app/models' + module_prefixes.map(&:underscore).join('/') + '.rb')
793
797
  base_module._brick_const_missing(*args)
794
798
  # elsif base_module != Object
795
799
  # module_parent.const_missing(*args)
@@ -811,7 +815,7 @@ class Object
811
815
  schema_name = [(singular_schema_name = base_name.underscore),
812
816
  (schema_name = singular_schema_name.pluralize),
813
817
  base_name,
814
- base_name.pluralize].find { |s| Brick.db_schemas.include?(s) }
818
+ base_name.pluralize].find { |s| Brick.db_schemas&.include?(s) }
815
819
  end
816
820
  plural_class_name = ActiveSupport::Inflector.pluralize(model_name = class_name)
817
821
  # If it's namespaced then we turn the first part into what would be a schema name
@@ -1141,16 +1145,18 @@ class Object
1141
1145
 
1142
1146
  self.protect_from_forgery unless: -> { self.request.format.js? }
1143
1147
  self.define_method :index do
1144
- if is_swagger
1145
- if !params&.key?('_brick_schema') &&
1146
- (referrer_params = request.env['HTTP_REFERER']&.split('?')&.last&.split('&')&.map { |x| x.split('=') }).present?
1147
- if params
1148
- referrer_params.each { |k, v| params.send(:parameters)[k] = v }
1149
- else
1150
- api_params = referrer_params&.to_h
1151
- end
1148
+ if (is_swagger || request.env['REQUEST_PATH'].start_with?(::Brick.api_root)) &&
1149
+ !params&.key?('_brick_schema') &&
1150
+ (referrer_params = request.env['HTTP_REFERER']&.split('?')&.last&.split('&')&.map { |x| x.split('=') }).present?
1151
+ if params
1152
+ referrer_params.each { |k, v| params.send(:parameters)[k] = v }
1153
+ else
1154
+ api_params = referrer_params&.to_h
1152
1155
  end
1153
- ::Brick.set_db_schema(params || api_params)
1156
+ end
1157
+ ::Brick.set_db_schema(params || api_params)
1158
+
1159
+ if is_swagger
1154
1160
  json = { 'openapi': '3.0.1', 'info': { 'title': Rswag::Ui.config.config_object[:urls].last&.fetch(:name, 'API documentation'), 'version': ::Brick.config.api_version },
1155
1161
  'servers': [
1156
1162
  { 'url': '{scheme}://{defaultHost}', 'variables': {
@@ -1432,6 +1438,27 @@ module ActiveRecord::ConnectionHandling
1432
1438
  alias _brick_establish_connection establish_connection
1433
1439
  def establish_connection(*args)
1434
1440
  conn = _brick_establish_connection(*args)
1441
+ # Overwrite SQLite's #begin_db_transaction so it opens in IMMEDIATE mode instead of
1442
+ # the default DEFERRED mode.
1443
+ # https://discuss.rubyonrails.org/t/failed-write-transaction-upgrades-in-sqlite3/81480/2
1444
+ if ActiveRecord::Base.connection.adapter_name == 'SQLite'
1445
+ arca = ::ActiveRecord::ConnectionAdapters
1446
+ db_statements = arca::SQLite3::DatabaseStatements
1447
+ # Rails 7.1 and later
1448
+ if arca::AbstractAdapter.private_instance_methods.include?(:with_raw_connection)
1449
+ db_statements.define_method(:begin_db_transaction) do
1450
+ log("begin immediate transaction", "TRANSACTION") do
1451
+ with_raw_connection(allow_retry: true, uses_transaction: false) do |conn|
1452
+ conn.transaction(:immediate)
1453
+ end
1454
+ end
1455
+ end
1456
+ else # Rails < 7.1
1457
+ db_statements.define_method(:begin_db_transaction) do
1458
+ log('begin immediate transaction', 'TRANSACTION') { @connection.transaction(:immediate) }
1459
+ end
1460
+ end
1461
+ end
1435
1462
  begin
1436
1463
  _brick_reflect_tables
1437
1464
  rescue ActiveRecord::NoDatabaseError
@@ -1445,13 +1472,13 @@ module ActiveRecord::ConnectionHandling
1445
1472
  initializer_loaded = false
1446
1473
  if (relations = ::Brick.relations).empty?
1447
1474
  # If there's schema things configured then we only expect our initializer to be named exactly this
1448
- if File.exist?(brick_initializer = Rails.root.join('config/initializers/brick.rb'))
1475
+ if File.exist?(brick_initializer = ::Rails.root.join('config/initializers/brick.rb'))
1449
1476
  initializer_loaded = load brick_initializer
1450
1477
  end
1451
1478
  # Load the initializer for the Apartment gem a little early so that if .excluded_models and
1452
1479
  # .default_schema are specified then we can work with non-tenanted models more appropriately
1453
1480
  apartment = Object.const_defined?('Apartment')
1454
- if apartment && File.exist?(apartment_initializer = Rails.root.join('config/initializers/apartment.rb'))
1481
+ if apartment && File.exist?(apartment_initializer = ::Rails.root.join('config/initializers/apartment.rb'))
1455
1482
  load apartment_initializer
1456
1483
  apartment_excluded = Apartment.excluded_models
1457
1484
  end
@@ -1701,48 +1728,18 @@ ORDER BY 1, 2, c.internal_column_id, acc.position"
1701
1728
  end
1702
1729
  end
1703
1730
 
1704
- tables = []
1705
- views = []
1706
- table_class_length = 0
1707
- view_class_length = 0
1708
1731
  relations.each do |k, v|
1709
- name_parts = k.split('.')
1710
- idx = 1
1711
- name_parts = name_parts.map do |x|
1712
- (idx += 1) <= name_parts.length ? x : x.singularize
1713
- end
1714
- name_parts.shift if apartment && name_parts.length > 1 && name_parts.first == Apartment.default_schema
1715
- class_name = name_parts.map(&:camelize).join('::')
1716
- if v.key?(:isView)
1717
- view_class_length = class_name.length if class_name.length > view_class_length
1718
- views
1719
- else
1720
- table_class_length = class_name.length if class_name.length > table_class_length
1721
- tables
1722
- end << [class_name, name_parts]
1732
+ rel_name = k.split('.').map { |rel_part| ::Brick.namify(rel_part, :underscore) }
1733
+ schema_names = rel_name[0..-2]
1734
+ schema_names.shift if ::Brick.apartment_multitenant && schema_names.first == Apartment.default_schema
1735
+ v[:schema] = schema_names.join('.') unless schema_names.empty?
1736
+ # %%% If more than one schema has the same table name, will need to add a schema name prefix to have uniqueness
1737
+ v[:resource] = rel_name.last
1738
+ v[:class_name] = (schema_names + [rel_name.last.singularize]).map(&:camelize).join('::')
1723
1739
  end
1724
- puts "\n" if tables.present? || views.present?
1725
- if tables.present?
1726
- puts "Classes that can be built from tables:"
1727
- display_classes(tables, table_class_length)
1728
- end
1729
- if views.present?
1730
- puts "Classes that can be built from views:"
1731
- display_classes(views, view_class_length)
1732
- end
1733
-
1734
1740
  ::Brick.load_additional_references if initializer_loaded
1735
1741
  end
1736
1742
 
1737
- def display_classes(rels, max_length)
1738
- rels.sort.each do |rel|
1739
- rel_link = rel.last.dup.map(&:underscore)
1740
- rel_link[-1] = rel_link[-1]
1741
- puts "#{rel.first}#{' ' * (max_length - rel.first.length)} /#{rel_link.join('/')}"
1742
- end
1743
- puts "\n"
1744
- end
1745
-
1746
1743
  def retrieve_schema_and_tables(sql = nil, is_postgres = nil, is_mssql = nil, schema = nil)
1747
1744
  is_mssql = ActiveRecord::Base.connection.adapter_name == 'SQLServer' if is_mssql.nil?
1748
1745
  sql ||= "SELECT t.table_schema AS \"schema\", t.table_name AS relation_name, t.table_type,#{"
@@ -2008,14 +2005,7 @@ module Brick
2008
2005
  end
2009
2006
  end
2010
2007
  end
2011
- if ::ActiveSupport.version < ::Gem::Version.new('6') ||
2012
- ::Rails.configuration.instance_variable_get(:@autoloader) == :classic
2013
- Rails.configuration.eager_load_namespaces.select { |ns| ns < Rails::Application }.each(&:eager_load!)
2014
- else
2015
- Zeitwerk::Loader.eager_load_all
2016
- end
2017
- abstract_activerecord_bases = ActiveRecord::Base.descendants.select { |ar| ar.abstract_class? }.map(&:name)
2018
- # abstract_activerecord_bases << ActiveRecord::Base
2008
+ abstract_activerecord_bases = ::Brick.eager_load_classes(true)
2019
2009
  models = if Dir.exist?(model_path = "#{rails_root}/app/models")
2020
2010
  Dir["#{model_path}/**/*.rb"].each_with_object({}) do |v, s|
2021
2011
  File.read(v).split("\n").each do |line|
@@ -72,7 +72,6 @@ module Brick
72
72
  def set_brick_model(find_args)
73
73
  # Need to return true if we can fill in the blanks for a missing one
74
74
  # args will be something like: ["index", ["categories"]]
75
- find_args[1] = find_args[1].each_with_object([]) { |a, s| s.concat(a.split('/')) }
76
75
  if (class_name = find_args[1].last&.singularize)
77
76
  find_args[1][find_args[1].length - 1] = class_name # Make sure the last item, defining the class name, is singular
78
77
  if (model = find_args[1].map(&:camelize).join('::').constantize) && (
@@ -100,10 +99,13 @@ module Brick
100
99
  def find_template(*args, **options)
101
100
  unless (model_name = @_brick_model&.name) ||
102
101
  (is_status = ::Brick.config.add_status && args[0..1] == ['status', ['brick_gem']]) ||
103
- (is_orphans = ::Brick.config.add_orphans && args[0..1] == ['orphans', ['brick_gem']]) ||
104
- # Used to also have: ActionView.version < ::Gem::Version.new('5.0') &&
105
- (model_name = (args[1].is_a?(Array) ? set_brick_model(args) : nil)&.name)
106
- return _brick_find_template(*args, **options)
102
+ (is_orphans = ::Brick.config.add_orphans && args[0..1] == ['orphans', ['brick_gem']])
103
+ if (possible_template = _brick_find_template(*args, **options))
104
+ return possible_template
105
+ else
106
+ # Used to also have: ActionView.version < ::Gem::Version.new('5.0') &&
107
+ model_name = (args[1].is_a?(Array) ? set_brick_model(args) : nil)&.name
108
+ end
107
109
  end
108
110
 
109
111
  if @_brick_model
@@ -726,7 +728,7 @@ erDiagram
726
728
  <td><h1>#{model_name}</h1></td>
727
729
  <td id=\"imgErd\" title=\"Show ERD\"></td>
728
730
  </tr></table>#{template_link}<%
729
- if (description = (relation = Brick.relations[#{model_name}.table_name])&.fetch(:description, nil)) %><%=
731
+ if (description = (relation = Brick.relations[#{model_name}.table_name])&.fetch(:description, nil)).present? %><%=
730
732
  description %><br><%
731
733
  end
732
734
  # FILTER PARAMETERS
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 73
8
+ TINY = 75
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -123,7 +123,7 @@ module Brick
123
123
  end
124
124
 
125
125
  class << self
126
- attr_accessor :default_schema, :db_schemas, :routes_done, :is_oracle
126
+ attr_accessor :default_schema, :db_schemas, :routes_done, :is_oracle, :is_eager_loading
127
127
 
128
128
  def set_db_schema(params = nil)
129
129
  schema = (params ? params['_brick_schema'] : ::Brick.default_schema) || 'public'
@@ -494,6 +494,28 @@ In config/initializers/brick.rb appropriate entries would look something like:
494
494
  def version
495
495
  VERSION::STRING
496
496
  end
497
+
498
+ def eager_load_classes(do_ar_abstract_bases = false)
499
+ ::Brick.is_eager_loading = true
500
+ if ::ActiveSupport.version < ::Gem::Version.new('6') ||
501
+ ::Rails.configuration.instance_variable_get(:@autoloader) == :classic
502
+ ::Rails.configuration.eager_load_namespaces.select { |ns| ns < ::Rails::Application }.each(&:eager_load!)
503
+ else
504
+ Zeitwerk::Loader.eager_load_all
505
+ end
506
+ abstract_ar_bases = if do_ar_abstract_bases
507
+ ActiveRecord::Base.descendants.select { |ar| ar.abstract_class? }.map(&:name)
508
+ end
509
+ ::Brick.is_eager_loading = false
510
+ abstract_ar_bases
511
+ end
512
+
513
+ def display_classes(rels, max_length)
514
+ rels.sort.each do |rel|
515
+ puts "#{rel.first}#{' ' * (max_length - rel.first.length)} /#{rel.last}"
516
+ end
517
+ puts "\n"
518
+ end
497
519
  end
498
520
 
499
521
  module RouteSet
@@ -501,35 +523,59 @@ In config/initializers/brick.rb appropriate entries would look something like:
501
523
  return super if ::Brick.routes_done
502
524
 
503
525
  ::Brick.routes_done = true
526
+ tables = []
527
+ views = []
528
+ table_class_length = 38 # Length of "Classes that can be built from tables:"
529
+ view_class_length = 37 # Length of "Classes that can be built from views:"
504
530
  existing_controllers = routes.each_with_object({}) { |r, s| c = r.defaults[:controller]; s[c] = nil if c }
505
531
  ::Rails.application.routes.append do
506
532
  # %%% TODO: If no auto-controllers then enumerate the controllers folder in order to build matching routes
507
533
  # If auto-controllers and auto-models are both enabled then this makes sense:
508
- ::Brick.relations.each do |rel_name, v|
509
- rel_name = rel_name.split('.').map { |rel_part| ::Brick.namify(rel_part, :underscore) }
510
- schema_names = rel_name[0..-2]
511
- schema_names.shift if ::Brick.apartment_multitenant && schema_names.first == Apartment.default_schema
512
- # %%% If more than one schema has the same table name, will need to add a schema name prefix to have uniqueness
513
- k = rel_name.last
514
- unless existing_controllers.key?(controller_name = k.pluralize)
534
+ ::Brick.relations.each do |k, v|
535
+ unless !(controller_name = v.fetch(:resource, nil)&.pluralize) || existing_controllers.key?(controller_name)
515
536
  options = {}
516
537
  options[:only] = [:index, :show] if v.key?(:isView)
517
- if schema_names.present? # && !Object.const_defined('Apartment')
518
- send(:namespace, schema_names.first) do
519
- send(:resources, k.to_sym, **options)
538
+ full_resource = nil
539
+ if (schema_name = v.fetch(:schema, nil)) # && !Object.const_defined('Apartment')
540
+ send(:namespace, schema_name) do
541
+ send(:resources, v[:resource].to_sym, **options)
520
542
  end
521
- send(:get, "/api/v1/#{schema_names.first}/#{k}", { to: "#{schema_names.first}/#{controller_name}#index" }) if Object.const_defined?('Rswag::Ui')
543
+ full_resource = "#{schema_name}/#{v[:resource]}"
544
+ send(:get, "#{::Brick.api_root}#{full_resource}", { to: "#{schema_name}/#{controller_name}#index" }) if Object.const_defined?('Rswag::Ui')
522
545
  else
523
- send(:resources, k.to_sym, **options)
524
- send(:get, "/api/v1/#{k}", { to: "#{controller_name}#index" }) if Object.const_defined?('Rswag::Ui')
546
+ send(:resources, v[:resource].to_sym, **options)
547
+ # Normally goes to something like: /api/v1/employees
548
+ send(:get, "#{::Brick.api_root}#{v[:resource]}", { to: "#{controller_name}#index" }) if Object.const_defined?('Rswag::Ui')
549
+ end
550
+
551
+ if (class_name = v.fetch(:class_name, nil))
552
+ if v.key?(:isView)
553
+ view_class_length = class_name.length if class_name.length > view_class_length
554
+ views
555
+ else
556
+ table_class_length = class_name.length if class_name.length > table_class_length
557
+ tables
558
+ end << [class_name, full_resource || v[:resource]]
525
559
  end
526
560
  end
527
- if ::Brick.config.add_status && instance_variable_get(:@set).named_routes.names.exclude?(:brick_status)
528
- get('/brick_status', to: 'brick_gem#status', as: 'brick_status')
529
- end
530
- if ::Brick.config.add_orphans && instance_variable_get(:@set).named_routes.names.exclude?(:brick_orphans)
531
- get('/brick_orphans', to: 'brick_gem#orphans', as: 'brick_orphans')
532
- end
561
+ end
562
+ puts "\n" if tables.present? || views.present?
563
+ if tables.present?
564
+ puts "Classes that can be built from tables:#{' ' * (table_class_length - 38)} Path:"
565
+ puts "======================================#{' ' * (table_class_length - 38)} ====="
566
+ ::Brick.display_classes(tables, table_class_length)
567
+ end
568
+ if views.present?
569
+ puts "Classes that can be built from views:#{' ' * (view_class_length - 37)} Path:"
570
+ puts "=====================================#{' ' * (view_class_length - 37)} ====="
571
+ ::Brick.display_classes(views, view_class_length)
572
+ end
573
+
574
+ if ::Brick.config.add_status && instance_variable_get(:@set).named_routes.names.exclude?(:brick_status)
575
+ get('/brick_status', to: 'brick_gem#status', as: 'brick_status')
576
+ end
577
+ if ::Brick.config.add_orphans && instance_variable_get(:@set).named_routes.names.exclude?(:brick_orphans)
578
+ get('/brick_orphans', to: 'brick_gem#orphans', as: 'brick_orphans')
533
579
  end
534
580
  if Object.const_defined?('Rswag::Ui') && doc_endpoint = Rswag::Ui.config.config_object[:urls].last
535
581
  # Serves JSON swagger info from a path such as '/api-docs/v1/swagger.json'
@@ -562,12 +608,12 @@ require 'active_record/relation/query_methods' if ActiveRecord.version < ::Gem::
562
608
  require 'rails/railtie' if ActiveRecord.version < ::Gem::Version.new('4.2')
563
609
 
564
610
  # Rake tasks
565
- class Railtie < Rails::Railtie
611
+ class Railtie < ::Rails::Railtie
566
612
  Dir.glob("#{File.expand_path(__dir__)}/brick/tasks/**/*.rake").each { |task| load task }
567
613
  end
568
614
 
569
615
  # Rails < 4.2 does not have env
570
- module Rails
616
+ module ::Rails
571
617
  unless respond_to?(:env)
572
618
  def self.env
573
619
  @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
@@ -147,7 +147,7 @@ module Brick
147
147
  # Brick.enable_controllers = true # Setting this to \"false\" will disable controllers in development
148
148
  # Brick.enable_views = true # Setting this to \"false\" will disable views in development
149
149
 
150
- # Brick.api_root = '/api/v1/' # Path from which to serve out API resources when the RSwag gem is present
150
+ # ::Brick.api_root = '/api/v1/' # Path from which to serve out API resources when the RSwag gem is present
151
151
 
152
152
  # # By default models are auto-created for database views, and set to be read-only. This can be skipped.
153
153
  # Brick.skip_database_views = true
@@ -55,7 +55,7 @@ module Brick
55
55
  # If Apartment is active, see if a default schema to analyse is indicated
56
56
 
57
57
  # # Load all models
58
- # Rails.configuration.eager_load_namespaces.select { |ns| ns < Rails::Application }.each(&:eager_load!)
58
+ # ::Brick.eager_load_classes
59
59
 
60
60
  if (tables = ::Brick.relations.reject { |k, v| v.key?(:isView) && v[:isView] == true }.map(&:first).sort).empty?
61
61
  puts "No tables found in database #{ActiveRecord::Base.connection.current_database}."
@@ -16,12 +16,7 @@ module Brick
16
16
  # %%% If Apartment is active and there's no schema_to_analyse, ask which schema they want
17
17
 
18
18
  # Load all models
19
- if ::ActiveSupport.version < ::Gem::Version.new('6') ||
20
- ::Rails.configuration.instance_variable_get(:@autoloader) == :classic
21
- Rails.configuration.eager_load_namespaces.select { |ns| ns < Rails::Application }.each(&:eager_load!)
22
- else
23
- Zeitwerk::Loader.eager_load_all
24
- end
19
+ ::Brick.eager_load_classes
25
20
 
26
21
  # Generate a list of viable models that can be chosen
27
22
  longest_length = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.73
4
+ version: 1.0.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord