brick 1.0.170 → 1.0.171

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: 3f802431e56f45276546a47b94f3571a6b23a2d0701c34b1f27964fd7ecf5b8f
4
- data.tar.gz: 3fd88c0f0626bc9abf08e9317187baf3e755adb5840ac9b56b18c04ddc2577c7
3
+ metadata.gz: 3632cff341398d0856d985613943d45da5a4de86797c1c59f0e38e31218e8e3d
4
+ data.tar.gz: cd8374ed7f930d8eb17fa12b7947a00d973571dc493f7ecc677350d8be0cfe75
5
5
  SHA512:
6
- metadata.gz: 3d5e4731d7956222b2c0ab28f19c5ac60addcea87b556a0765dd28a998c2364148bb348a57a9b3541096da71c6d9e2a4440cf6a038fb40d0b2d5c42aadf01ce5
7
- data.tar.gz: c955e2d400887fe6e8ff3869bb6ca2e5a996898187e47d16764676b36e6a68a9ece28cf5593e993760c960cb25ba9c479904a2e327e824dd485e592df0d72d79
6
+ metadata.gz: 66814142c86e8066bb0a72aba93df3a0a826b9ca48cd14dd547291e27079399ed344e41c547dbd4c5fd26d98f7d361e9ad73c7a3bb53e96ec165c1b1b87a478a
7
+ data.tar.gz: e17de43008cd2b7e1a8ed62aad8cc428248f145e024266e7f4237f892d844d08a6cdc238c650c46986a9f1a1038d87cc7bd16531ad532bc25f2e6f7bc1a2af9b
@@ -1676,7 +1676,7 @@ class Object
1676
1676
  # options[:source] = other.first[:inverse][:assoc_name].to_sym
1677
1677
  # And also has been:
1678
1678
  # hm.first[:inverse][:assoc_name].to_sym
1679
- options[:source] = hm.last.to_sym
1679
+ options[:source] = hm[1].to_sym
1680
1680
  else
1681
1681
  through = hm.first.fetch(:alternate_chosen_name, hm.first[:alternate_name])
1682
1682
  end
@@ -1692,11 +1692,11 @@ class Object
1692
1692
  # Was:
1693
1693
  # options[:class_name] = hm.first[:inverse_table].singularize.camelize
1694
1694
  # options[:foreign_key] = hm.first[:fk].to_sym
1695
- far_assoc = relations[hm.first[:inverse_table]][:fks].find { |_k, v| v[:assoc_name] == hm.last }
1695
+ far_assoc = relations[hm.first[:inverse_table]][:fks].find { |_k, v| v[:assoc_name] == hm[1] }
1696
1696
  options[:class_name] = far_assoc.last[:inverse_table].singularize.camelize
1697
1697
  options[:foreign_key] = far_assoc.last[:fk].to_sym
1698
1698
  end
1699
- options[:source] ||= hm.last.to_sym unless hmt_name.singularize == hm.last
1699
+ options[:source] ||= hm[1].to_sym unless hmt_name.singularize == hm[1]
1700
1700
  code << " has_many :#{hmt_name}#{options.map { |opt| ", #{opt.first}: #{opt.last.inspect}" }.join}\n"
1701
1701
  new_model_class.send(:has_many, hmt_name.to_sym, **options)
1702
1702
  end
@@ -1805,11 +1805,11 @@ class Object
1805
1805
  end
1806
1806
 
1807
1807
  # Add any relevant user-requested HMTs
1808
- Brick.config.hmts.each do |hmt|
1808
+ Brick.config.hmts&.each do |hmt|
1809
1809
  # Make sure this HMT lines up with the current HM
1810
1810
  next unless hmt.first == table_name && hmt[1] == inverse_table &&
1811
1811
  # And has not already been auto-created
1812
- !(y = hmts.fetch(hmt[2], nil)&.find { |x| x.first[:assoc_name] == hmt[1] })
1812
+ !(hmts.fetch(hmt[2], nil)&.any? { |existing_hmt| existing_hmt.first[:assoc_name] == hmt[1] })
1813
1813
 
1814
1814
  # Good so far -- now see if we have appropriate HM -> BT/HM associations by which we can create this user-requested HMT
1815
1815
  if (hm_assoc = relation[:fks].find { |_k, v| !v[:is_bt] && v[:assoc_name] == hmt[1] }.last) &&
@@ -1669,8 +1669,8 @@ end
1669
1669
  brick_form_for(obj, options, #{model_name}, bts, #{pk.inspect}) %>
1670
1670
 
1671
1671
  #{unless args.first == 'new'
1672
- # Was: confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete #\{model_name} -- Are you sure?' }" : "form: { data: { turbo_confirm: 'Delete #\{model_name} -- Are you sure?' } }"
1673
- confirm_are_you_sure = "data: { confirm: 'Delete #\{model_name} -- Are you sure?' }"
1672
+ # Was: confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: \"Delete #\{model_name} -- Are you sure?\" }" : "form: { data: { turbo_confirm: \"Delete #\{model_name} -- Are you sure?\" } }"
1673
+ confirm_are_you_sure = "data: { confirm: \"Delete #\{model_name} -- Are you sure?\" }"
1674
1674
  ret = +"<%= button_to(\"Delete #\{@#{obj_name}.brick_descrip}\", send(\"#\{#{model_name}._brick_index(:singular)}_path\".to_sym, @#{obj_name}), { method: 'delete', class: 'danger', #{confirm_are_you_sure} }) %>"
1675
1675
  hms_headers.each_with_object(ret) do |hm, s|
1676
1676
  # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 170
8
+ TINY = 171
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
@@ -278,7 +278,8 @@ module Brick
278
278
  if (through = hmt.last.options[:through])
279
279
  # ::Brick.relations[hmt.last.through_reflection.table_name]
280
280
  skip_hms[through] = nil if hms[through] && model.is_brick? &&
281
- hmt.last.klass != hmt.last.active_record # Don't pull HMs for HMTs that point back to the same table
281
+ hmt.last.klass != hmt.last.active_record && # Don't pull HMs for HMTs that point back to the same table
282
+ hmt[1].source_reflection.belongs_to? # Don't pull HMs when the HMT is built from HM -> HM
282
283
  # End up with a hash of HMT names pointing to join-table associations
283
284
  model._br_associatives[hmt.first] = hms[through] # || hms["#{(opt = hmt.last.options)[:through].to_s.singularize}_#{opt[:source].to_s.pluralize}".to_sym]
284
285
  end
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.170
4
+ version: 1.0.171
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits