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 +4 -4
- data/lib/brick/extensions.rb +25 -23
- data/lib/brick/frameworks/rails/engine.rb +1 -2
- data/lib/brick/version_number.rb +1 -1
- data/lib/generators/brick/install_generator.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30eeeb5fb81003f790234885589b29f227b7f4f2d498accb07da5cd8ea425084
|
4
|
+
data.tar.gz: 1841386c2750c2aef744a7ee555b649e2fc0298367684d261faf64297b8430c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c5747800aaa5469f2ff2b0be3ae5056fa383c6d246e7aff15b19eb4a588e15e72f5d1ecb384879b3b7f175cab28961fb4984e11d5994085b215f442d722389
|
7
|
+
data.tar.gz: ec3418092244d97b3006086aaf0484ee1ab4342cf2c16716239f7127c8e23056dc25e1714e51523bdb8f87fb6b88c322dabefb096fe7bf0b1f695568b636d4b8
|
data/lib/brick/extensions.rb
CHANGED
@@ -176,25 +176,27 @@ module ActiveRecord
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
::Brick.
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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 =
|
407
|
+
singular_assoc_name = fk.first[:inverse][:assoc_name].singularize
|
407
408
|
source = fk.last
|
408
|
-
through =
|
409
|
+
through = fk.first[:alternate_name].pluralize
|
409
410
|
"#{singular_assoc_name}_#{hmt_fk}"
|
410
411
|
else
|
411
|
-
|
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 %>
|
data/lib/brick/version_number.rb
CHANGED
@@ -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
|
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.
|