brick 1.0.15 → 1.0.16

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: 2dbd4fef7ab5c2796e75a0bce86316be00ebceb02aa5a0b8053f75b27d433c57
4
- data.tar.gz: daa2802b2fec6533ccfed8fa9178129c6633f92b83fb092fefa48a657cb36e9b
3
+ metadata.gz: 30eeeb5fb81003f790234885589b29f227b7f4f2d498accb07da5cd8ea425084
4
+ data.tar.gz: 1841386c2750c2aef744a7ee555b649e2fc0298367684d261faf64297b8430c0
5
5
  SHA512:
6
- metadata.gz: 33f97461748561fb21900ccb1b4b39c13803e68e04fea807851b467587907577a10bd5b5a2470cde5f50bca019d3cc986b512545bf700477028f68751bb95e6a
7
- data.tar.gz: 97605afbe32e2509800f510ca2984651cc196c048a6267fa31d65363815bc6f4484955aacd45fae1553fe70453f1bee283766812a2f92678bc35e516ec594738
6
+ metadata.gz: 64c5747800aaa5469f2ff2b0be3ae5056fa383c6d246e7aff15b19eb4a588e15e72f5d1ecb384879b3b7f175cab28961fb4984e11d5994085b215f442d722389
7
+ data.tar.gz: ec3418092244d97b3006086aaf0484ee1ab4342cf2c16716239f7127c8e23056dc25e1714e51523bdb8f87fb6b88c322dabefb096fe7bf0b1f695568b636d4b8
@@ -176,25 +176,27 @@ module ActiveRecord
176
176
  end
177
177
  end
178
178
 
179
- module ActiveSupport::Dependencies
180
- class << self
181
- # %%% Probably a little more targeted than other approaches we've taken thusfar
182
- # This happens before the whole parent check
183
- alias _brick_autoload_module! autoload_module!
184
- def autoload_module!(*args)
185
- into, const_name, qualified_name, path_suffix = args
186
- if (base_class = ::Brick.config.sti_namespace_prefixes&.fetch("::#{into.name}::", nil)&.constantize)
187
- ::Brick.sti_models[qualified_name] = { base: base_class }
188
- # Build subclass and place it into the specially STI-namespaced module
189
- into.const_set(const_name.to_sym, klass = Class.new(base_class))
190
- # %%% used to also have: autoload_once_paths.include?(base_path) ||
191
- autoloaded_constants << qualified_name unless autoloaded_constants.include?(qualified_name)
192
- klass
193
- elsif (base_class = ::Brick.config.sti_namespace_prefixes&.fetch("::#{const_name}", nil)&.constantize)
194
- # Build subclass and place it into Object
195
- Object.const_set(const_name.to_sym, klass = Class.new(base_class))
196
- else
197
- _brick_autoload_module!(*args)
179
+ if ActiveSupport::Dependencies.respond_to?(:autoload_module!) # %%% Only works with previous non-zeitwerk auto-loading
180
+ module ActiveSupport::Dependencies
181
+ class << self
182
+ # %%% Probably a little more targeted than other approaches we've taken thusfar
183
+ # This happens before the whole parent check
184
+ alias _brick_autoload_module! autoload_module!
185
+ def autoload_module!(*args)
186
+ into, const_name, qualified_name, path_suffix = args
187
+ if (base_class = ::Brick.config.sti_namespace_prefixes&.fetch("::#{into.name}::", nil)&.constantize)
188
+ ::Brick.sti_models[qualified_name] = { base: base_class }
189
+ # Build subclass and place it into the specially STI-namespaced module
190
+ into.const_set(const_name.to_sym, klass = Class.new(base_class))
191
+ # %%% used to also have: autoload_once_paths.include?(base_path) ||
192
+ autoloaded_constants << qualified_name unless autoloaded_constants.include?(qualified_name)
193
+ klass
194
+ elsif (base_class = ::Brick.config.sti_namespace_prefixes&.fetch("::#{const_name}", nil)&.constantize)
195
+ # Build subclass and place it into Object
196
+ Object.const_set(const_name.to_sym, klass = Class.new(base_class))
197
+ else
198
+ _brick_autoload_module!(*args)
199
+ end
198
200
  end
199
201
  end
200
202
  end
@@ -333,7 +335,6 @@ class Object
333
335
  singular_table_name = ActiveSupport::Inflector.singularize(assoc[:inverse_table])
334
336
  macro = if assoc[:is_bt]
335
337
  # Try to take care of screwy names if this is a belongs_to going to an STI subclass
336
- # binding.pry if assoc[:fk] == 'issue_severity_id'
337
338
  if (primary_class = assoc.fetch(:primary_class, nil)) &&
338
339
  (sti_inverse_assoc = primary_class.reflect_on_all_associations.find { |a| a.macro == :has_many && a.options[:class_name] == self.name && assoc[:fk] = a.foreign_key })
339
340
  assoc_name = sti_inverse_assoc.options[:inverse_of].to_s || assoc_name
@@ -403,12 +404,13 @@ class Object
403
404
  fks.each do |fk|
404
405
  source = nil
405
406
  this_hmt_fk = if fks.length > 1
406
- singular_assoc_name = ActiveSupport::Inflector.singularize(fk.first[:inverse][:assoc_name])
407
+ singular_assoc_name = fk.first[:inverse][:assoc_name].singularize
407
408
  source = fk.last
408
- through = ActiveSupport::Inflector.pluralize(fk.first[:alternate_name])
409
+ through = fk.first[:alternate_name].pluralize
409
410
  "#{singular_assoc_name}_#{hmt_fk}"
410
411
  else
411
- through = fk.first[:assoc_name]
412
+ source = fk.last unless hmt_fk.singularize == fk.last
413
+ through = fk.first[:assoc_name].pluralize
412
414
  hmt_fk
413
415
  end
414
416
  code << " has_many :#{this_hmt_fk}, through: #{(assoc_name = through.to_sym).to_sym.inspect}#{", source: :#{source}" if source}\n"
@@ -90,7 +90,6 @@ module Brick
90
90
 
91
91
  schema_options = ::Brick.db_schemas.each_with_object(+'') { |v, s| s << "<option value=\"#{v}\">#{v}</option>" }.html_safe
92
92
  hms_columns = +'' # Used for 'index'
93
- # puts skip_hms.inspect
94
93
  hms_headers = hms.each_with_object([]) do |hm, s|
95
94
  next if skip_hms.key?(hm.last.name)
96
95
 
@@ -270,7 +269,7 @@ function changeout(href, param, value) {
270
269
  <% if (collection = @#{obj_name}.first.#{hm_name}).empty? %>
271
270
  <tr><td>(none)</td></tr>
272
271
  <% else %>
273
- <% collection.order(#{pk.inspect}).uniq.each do |#{hm_singular_name = hm_name.singularize}| %>
272
+ <% collection.order(#{pk.inspect}).uniq.each do |#{hm_singular_name = hm_name.singularize.underscore}| %>
274
273
  <tr><td><%= link_to(#{hm_singular_name}.brick_descrip, #{hm_singular_name}_path(#{hm_singular_name}.#{pk})) %></td></tr>
275
274
  <% end %>
276
275
  <% end %>
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 15
8
+ TINY = 16
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
@@ -94,7 +94,7 @@ module Brick
94
94
  # # Any tables or views you'd like to skip when auto-creating models
95
95
  # Brick.exclude_tables = ['custom_metadata', 'version_info']
96
96
 
97
- # # Class for auto-generated models to inherit from
97
+ # # Class that auto-generated models should inherit from
98
98
  # Brick.models_inherit_from = ApplicationRecord
99
99
 
100
100
  # # When table names have specific prefixes automatically place them in their own module with a table_name_prefix.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits