brick 1.0.101 → 1.0.102

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eba38d653370b0cc3e98f2adc82d8c475854440745bd35caab9a9a4253fc152c
4
- data.tar.gz: 18ca517b90266cf5db711040a7f40c8e848600135ef0a39ad91da9cd2a0b1c89
3
+ metadata.gz: 167e29431250efc9170ec3f174cce913584c700ce8405a0d275c63636d04cf81
4
+ data.tar.gz: 34826b000c093ab4fb8d63edd4509d8244f3d5e3712066489e00076f67ba9704
5
5
  SHA512:
6
- metadata.gz: 859f48999fb0e8d1010a701e29c9f0275f716b20f54b4348576f4dbff7f68da1eb83709a51a1a7acd7debaf4dc1f82e863048ef16cda6b5f59862246e0c50787
7
- data.tar.gz: d93c3db79715f62705c0b8f2f5bd2640a2756e1fbcb6aa6a7cf017a18bc31fa5e98496ea41539611c149f84870f24596c105d146484519b7f040d2f36b25ce45
6
+ metadata.gz: e0d8d82c98b918c2a6b61c06a636ce60e2c4eaaed32b9556b09984f0b778f624cfb887cf9d82d48042cb75057b1e3688be661c05fa9c79f90052da32d029e1b2
7
+ data.tar.gz: 53c296598e9bc85ca2afd5456ff02d3c56fde7f79cd6de9f4684c5fcef0ad1be489e6ccda37c26b81a109393de1a10fa70a08d352825e69437ffdcd8b2bb2bfe
@@ -119,30 +119,32 @@ module ActiveRecord
119
119
  end
120
120
  s << part_sym
121
121
  end
122
- if (parts = prefix + first_parts + [parts[-1]]).length > 1 && klass
123
- unless is_polymorphic
124
- s = build_array
125
- parts[0..-3].each { |v| s = s[v.to_sym] }
126
- s[parts[-2]] = nil # unless parts[-2].empty? # Using []= will "hydrate" any missing part(s) in our whole series
127
- end
128
- translations[parts[0..-2].join('.')] = klass
129
- end
130
- if klass&.column_names.exclude?(parts.last) &&
131
- (klass = (orig_class = klass).reflect_on_association(possible_dsl = parts.pop.to_sym)&.klass)
132
- if prefix.empty? # Custom columns start with an empty prefix
133
- prefix << parts.shift until parts.empty?
122
+ if first_parts
123
+ if (parts = prefix + first_parts + [parts[-1]]).length > 1 && klass
124
+ unless is_polymorphic
125
+ s = build_array
126
+ parts[0..-3].each { |v| s = s[v.to_sym] }
127
+ s[parts[-2]] = nil # unless parts[-2].empty? # Using []= will "hydrate" any missing part(s) in our whole series
128
+ end
129
+ translations[parts[0..-2].join('.')] = klass
134
130
  end
135
- # Expand this entry which refers to an association name
136
- members2, dsl2a = klass.brick_parse_dsl(build_array, prefix + [possible_dsl], translations, is_polymorphic, nil, true)
137
- members += members2
138
- dsl2 << dsl2a
139
- dsl3 << dsl2a
140
- else
141
- dsl2 << "[#{bracket_name}]"
142
- if emit_dsl
143
- dsl3 << "[#{prefix[1..-1].map { |p| "#{p.to_s}." }.join if prefix.length > 1}#{bracket_name}]"
131
+ if klass&.column_names.exclude?(parts.last) &&
132
+ (klass = (orig_class = klass).reflect_on_association(possible_dsl = parts.pop.to_sym)&.klass)
133
+ if prefix.empty? # Custom columns start with an empty prefix
134
+ prefix << parts.shift until parts.empty?
135
+ end
136
+ # Expand this entry which refers to an association name
137
+ members2, dsl2a = klass.brick_parse_dsl(build_array, prefix + [possible_dsl], translations, is_polymorphic, nil, true)
138
+ members += members2
139
+ dsl2 << dsl2a
140
+ dsl3 << dsl2a
141
+ else
142
+ dsl2 << "[#{bracket_name}]"
143
+ if emit_dsl
144
+ dsl3 << "[#{prefix[1..-1].map { |p| "#{p.to_s}." }.join if prefix.length > 1}#{bracket_name}]"
145
+ end
146
+ members << parts
144
147
  end
145
- members << parts
146
148
  end
147
149
  bracket_name = nil
148
150
  else
@@ -409,7 +411,7 @@ module ActiveRecord
409
411
  model._brick_calculate_bts_hms(translations, join_array) if is_add_bts || is_add_hms
410
412
 
411
413
  is_postgres = ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
412
- is_mysql = ActiveRecord::Base.connection.adapter_name == 'Mysql2'
414
+ is_mysql = ['Mysql2', 'Trilogy'].include?(ActiveRecord::Base.connection.adapter_name)
413
415
  is_mssql = ActiveRecord::Base.connection.adapter_name == 'SQLServer'
414
416
  is_distinct = nil
415
417
  wheres = {}
@@ -557,7 +559,7 @@ module ActiveRecord
557
559
  brick_link = rel_dupe.brick_links[sel_col.first]
558
560
  field_tbl_name = brick_link&.split('.')&.last ||
559
561
  # ... so here's a best-effort guess for what the table name might be.
560
- rel_dupe.klass.reflect_on_association(sel_col.first).klass.table_name
562
+ rel_dupe.klass.reflect_on_association(sel_col.first)&.klass&.table_name
561
563
  # If it's Oracle, quote any AREL aliases that had been applied
562
564
  field_tbl_name = "\"#{field_tbl_name}\"" if ::Brick.is_oracle && rel_dupe.brick_links.values.include?(field_tbl_name)
563
565
 
@@ -803,7 +805,7 @@ JOIN (SELECT #{hm_selects.map { |s| "#{'br_t0.' if from_clause}#{s}" }.join(', '
803
805
  alias _brick_find_sti_class find_sti_class
804
806
  def find_sti_class(type_name)
805
807
  if ::Brick.sti_models.key?(type_name ||= name)
806
- _brick_find_sti_class(type_name)
808
+ ::Brick.sti_models[type_name].fetch(:base, nil) || _brick_find_sti_class(type_name)
807
809
  else
808
810
  # This auto-STI is more of a brute-force approach, building modules where needed
809
811
  # The more graceful alternative is the overload of ActiveSupport::Dependencies#autoload_module! found below
@@ -1407,7 +1409,7 @@ class Object
1407
1409
  singular_table_name = ActiveSupport::Inflector.singularize(ActiveSupport::Inflector.underscore(plural_class_name))
1408
1410
  pk = model&._brick_primary_key(relations.fetch(table_name, nil))
1409
1411
  is_postgres = ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
1410
- is_mysql = ActiveRecord::Base.connection.adapter_name == 'Mysql2'
1412
+ is_mysql = ['Mysql2', 'Trilogy'].include?(ActiveRecord::Base.connection.adapter_name)
1411
1413
 
1412
1414
  code = +"class #{class_name} < #{controller_base&.name || 'ApplicationController'}\n"
1413
1415
  built_controller = Class.new(controller_base || ActionController::Base) do |new_controller_class|
@@ -1622,6 +1624,18 @@ class Object
1622
1624
  end
1623
1625
 
1624
1626
  unless is_openapi || is_avo
1627
+ # Skip showing Bullet gem optimisation messages
1628
+ if Object.const_defined?('Bullet') && Bullet.respond_to?(:enable?)
1629
+ around_action :skip_bullet
1630
+ def skip_bullet
1631
+ bullet_enabled = Bullet.enable?
1632
+ Bullet.enable = false
1633
+ yield
1634
+ ensure
1635
+ Bullet.enable = bullet_enabled
1636
+ end
1637
+ end
1638
+
1625
1639
  _, order_by_txt = model._brick_calculate_ordering(default_ordering(table_name, pk)) if pk
1626
1640
  code << " def index\n"
1627
1641
  code << " @#{table_name.pluralize} = #{model.name}#{pk&.present? ? ".order(#{order_by_txt.join(', ')})" : '.all'}\n"
@@ -1935,7 +1949,7 @@ end.class_exec do
1935
1949
  puts "*** In the brick.rb initializer the line \"::Brick.schema_behavior = ...\" refers to schema(s) called #{possible_schemas.map { |s| "\"#{s}\"" }.join(', ')}. No mentioned schema exists. ***"
1936
1950
  end
1937
1951
  end
1938
- when 'Mysql2'
1952
+ when 'Mysql2', 'Trilogy'
1939
1953
  ::Brick.default_schema = schema = ActiveRecord::Base.connection.current_database
1940
1954
  when 'OracleEnhanced'
1941
1955
  # ActiveRecord::Base.connection.current_database will be something like "XEPDB1"
@@ -2070,7 +2084,7 @@ ORDER BY 1, 2, c.internal_column_id, acc.position"
2070
2084
  # end
2071
2085
  # schema = ::Brick.default_schema # Reset back for this next round of fun
2072
2086
  case ActiveRecord::Base.connection.adapter_name
2073
- when 'PostgreSQL', 'Mysql2', 'SQLServer'
2087
+ when 'PostgreSQL', 'Mysql2', 'Trilogy', 'SQLServer'
2074
2088
  sql = "SELECT kcu1.CONSTRAINT_SCHEMA, kcu1.TABLE_NAME, kcu1.COLUMN_NAME,
2075
2089
  kcu2.CONSTRAINT_SCHEMA AS primary_schema, kcu2.TABLE_NAME AS primary_table, kcu1.CONSTRAINT_NAME AS CONSTRAINT_SCHEMA_FK
2076
2090
  FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS rc
@@ -625,7 +625,7 @@ def display_value(col_type, val)
625
625
  case col_type
626
626
  when 'geometry', 'geography'
627
627
  if Object.const_defined?('RGeo')
628
- @is_mysql = ActiveRecord::Base.connection.adapter_name == 'Mysql2' if @is_mysql.nil?
628
+ @is_mysql = ['Mysql2', 'Trilogy'].include?(ActiveRecord::Base.connection.adapter_name) if @is_mysql.nil?
629
629
  @is_mssql = ActiveRecord::Base.connection.adapter_name == 'SQLServer' if @is_mssql.nil?
630
630
  val_err = nil
631
631
  if @is_mysql || @is_mssql
@@ -659,6 +659,8 @@ def display_value(col_type, val)
659
659
  else
660
660
  '(Add RGeo gem to parse geometry detail)'
661
661
  end
662
+ when :binary
663
+ display_binary(val) if val
662
664
  else
663
665
  if col_type
664
666
  hide_bcrypt(val)
@@ -667,6 +669,40 @@ def display_value(col_type, val)
667
669
  end
668
670
  end
669
671
  end
672
+
673
+ def image_signatures
674
+ @image_signatures ||= { \"\\xFF\\xD8\\xFF\\xEE\" => 'jpeg',
675
+ \"\\xFF\\xD8\\xFF\\xE0\\x00\\x10\\x4A\\x46\\x49\\x46\\x00\\x01\" => 'jpeg',
676
+ \"\\x89PNG\\r\\n\\x1A\\n\" => 'png',
677
+ '<svg' => 'svg+xml', # %%% Not yet very good detection for SVG
678
+ 'BM' => 'bmp',
679
+ 'GIF87a' => 'gif',
680
+ 'GIF89a' => 'gif' }
681
+ end
682
+ def display_binary(val)
683
+ if val[0..1] == \"\\x15\\x1C\" # One of those goofy Microsoft OLE containers?
684
+ package_header_length = val[2..3].bytes.reverse.inject(0) {|m, b| (m << 8) + b }
685
+ # This will often be just FF FF FF FF
686
+ # object_size = val[16..19].bytes.reverse.inject(0) {|m, b| (m << 8) + b }
687
+ friendly_and_class_names = val[20...package_header_length].split(\"\\0\")
688
+ object_type_name_length = val[package_header_length + 8..package_header_length+11].bytes.reverse.inject(0) {|m, b| (m << 8) + b }
689
+ friendly_and_class_names << val[package_header_length + 12...package_header_length + 12 + object_type_name_length].strip
690
+ # friendly_and_class_names will now be something like: ['Bitmap Image', 'Paint.Picture', 'PBrush']
691
+ real_object_size = val[package_header_length + 20 + object_type_name_length..package_header_length + 23 + object_type_name_length].bytes.reverse.inject(0) {|m, b| (m << 8) + b }
692
+ object_start = package_header_length + 24 + object_type_name_length
693
+ val = val[object_start...object_start + real_object_size]
694
+ end
695
+ if (signature = image_signatures.find { |k, _v| val[0...k.length] == k })
696
+ if val.length < 500_000
697
+ \"<img src=\\\"data:image/#\{signature.last};base64,#\{Base64.encode64(val)}\\\">\"
698
+ else
699
+ \"&lt;&nbsp;#\{signature.last} image, #\{val.length} bytes&nbsp;>\"
700
+ end
701
+ else
702
+ \"&lt;&nbsp;Binary, #\{val.length} bytes&nbsp;>\"
703
+ end
704
+ end
705
+
670
706
  # Accommodate composite primary keys that include strings with forward-slash characters
671
707
  def slashify(*vals)
672
708
  vals.map { |val_part| val_part.is_a?(String) ? val_part.gsub('/', '^^sl^^') : val_part }
@@ -1576,11 +1612,10 @@ document.querySelectorAll(\"input, select\").forEach(function (inp) {
1576
1612
  private
1577
1613
 
1578
1614
  alias _brick_render_template render_template
1579
- def render_template(view, template, *args)
1580
- result = _brick_render_template(view, template, *args)
1581
- if template.instance_variable_get(:@is_brick)
1582
- Apartment::Tenant.switch!(::Brick.apartment_default_tenant) if ::Brick.apartment_multitenant
1583
- end
1615
+ def render_template(view, template, layout_name, *args)
1616
+ layout_name = nil if (is_brick = template.instance_variable_get(:@is_brick)) && layout_name.is_a?(Proc)
1617
+ result = _brick_render_template(view, template, layout_name, *args)
1618
+ Apartment::Tenant.switch!(::Brick.apartment_default_tenant) if is_brick && ::Brick.apartment_multitenant
1584
1619
  result
1585
1620
  end
1586
1621
  end # TemplateRenderer
@@ -3,7 +3,7 @@ module Brick::Rails::FormTags
3
3
  def brick_grid(relation, bt_descrip, sequence = nil, inclusions, exclusions,
4
4
  cols, poly_cols, bts, hms_keys, hms_cols)
5
5
  out = "<table id=\"headerTop\"></table>
6
- <table id=\"#{relation.table_name}\" class=\"shadow\">
6
+ <table id=\"#{relation.table_name.split('.').last}\" class=\"shadow\">
7
7
  <thead><tr>"
8
8
  pk = (klass = relation.klass).primary_key || []
9
9
  pk = [pk] unless pk.is_a?(Array)
@@ -90,6 +90,7 @@ module Brick::Rails::FormTags
90
90
  # 0..62 because Postgres column names are limited to 63 characters
91
91
  obj, descrips[0..-2].map { |id| obj.send(id.last[0..62]) }, bt_id_col
92
92
  )
93
+ bt_txt = display_binary(bt_txt).html_safe if bt_txt&.encoding&.name == 'ASCII-8BIT'
93
94
  bt_txt ||= "<span class=\"orphan\">&lt;&lt; Orphaned ID: #{val} >></span>" if val
94
95
  bt_id = bt_id_col&.map { |id_col| obj.respond_to?(id_sym = id_col.to_sym) ? obj.send(id_sym) : id_col }
95
96
  out << (bt_id&.first ? link_to(bt_txt, send("#{bt_class.base_class._brick_index(:singular)}_path".to_sym, bt_id)) : bt_txt || '')
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 101
8
+ TINY = 102
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
@@ -26,7 +26,7 @@ end
26
26
  require 'brick/util'
27
27
 
28
28
  # Allow ActiveRecord < 3.2 to work with Ruby 2.7 and later
29
- if (ruby_version = ::Gem::Version.new(RUBY_VERSION)) >= ::Gem::Version.new('2.7')
29
+ if (is_ruby_2_7 = (ruby_version = ::Gem::Version.new(RUBY_VERSION)) >= ::Gem::Version.new('2.7'))
30
30
  if ActiveRecord.version < ::Gem::Version.new('3.2')
31
31
  # Remove circular reference for "now"
32
32
  ::Brick::Util._patch_require(
@@ -1043,6 +1043,18 @@ ActiveSupport.on_load(:active_record) do
1043
1043
  end
1044
1044
  # rubocop:enable Lint/ConstantDefinitionInBlock
1045
1045
 
1046
+ arsc = ::ActiveRecord::StatementCache
1047
+ if is_ruby_2_7 && (params = arsc.method(:create).parameters).length == 2 && params.last == [:opt, :block]
1048
+ arsc.class_exec do
1049
+ def self.create(connection, callable = nil, &block)
1050
+ relation = (callable || block).call ::ActiveRecord::StatementCache::Params.new
1051
+ bind_map = ::ActiveRecord::StatementCache::BindMap.new relation.bound_attributes
1052
+ query_builder = connection.cacheable_query(self, relation.arel)
1053
+ new query_builder, bind_map
1054
+ end
1055
+ end
1056
+ end
1057
+
1046
1058
  # Rails < 4.2 is not innately compatible with Ruby 2.4 and later, and comes up with:
1047
1059
  # "TypeError: Cannot visit Integer" unless we patch like this:
1048
1060
  if ruby_version >= ::Gem::Version.new('2.4') &&
@@ -1081,11 +1093,54 @@ ActiveSupport.on_load(:active_record) do
1081
1093
  end
1082
1094
  end
1083
1095
 
1096
+ if Psych.respond_to?(:unsafe_load) && ActiveRecord.version < ::Gem::Version.new('6.1')
1097
+ Psych.class_exec do
1098
+ class << self
1099
+ alias _original_load load
1100
+ def load(yaml, *args, **kwargs)
1101
+ if caller.first.end_with?("`database_configuration'") && kwargs[:aliases].nil?
1102
+ kwargs[:aliases] = true
1103
+ end
1104
+ _original_load(yaml, *args, **kwargs)
1105
+ end
1106
+ end
1107
+ end
1108
+ end
1109
+
1110
+ # def aliased_table_for(arel_table, table_name = nil)
1111
+ # table_name ||= arel_table.name
1112
+
1113
+ # if aliases[table_name] == 0
1114
+ # # If it's zero, we can have our table_name
1115
+ # aliases[table_name] = 1
1116
+ # arel_table = arel_table.alias(table_name) if arel_table.name != table_name
1117
+ # else
1118
+ # # Otherwise, we need to use an alias
1119
+ # aliased_name = @connection.table_alias_for(yield)
1120
+
1121
+ # # Update the count
1122
+ # count = aliases[aliased_name] += 1
1123
+
1124
+ # aliased_name = "#{truncate(aliased_name)}_#{count}" if count > 1
1125
+
1126
+ # arel_table = arel_table.alias(aliased_name)
1127
+ # end
1128
+
1129
+ # arel_table
1130
+ # end
1131
+ # def aliased_table_for(table_name, aliased_name, type_caster)
1132
+
1084
1133
  class ActiveRecord::Associations::JoinDependency
1085
- if JoinBase.instance_method(:initialize).arity == 2 # Older ActiveRecord 4.x?
1086
- def initialize(base, associations, joins)
1087
- @alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(base.connection, joins)
1088
- @alias_tracker.aliased_table_for(base.table_name, base.table_name) # Updates the count for base.table_name to 1
1134
+ if JoinBase.instance_method(:initialize).arity == 2 # Older ActiveRecord <= 5.1?
1135
+ def initialize(base, associations, joins, eager_loading: true)
1136
+ araat = ::ActiveRecord::Associations::AliasTracker
1137
+ if araat.respond_to?(:create_with_joins) # Rails 5.0 and 5.1
1138
+ @alias_tracker = araat.create_with_joins(base.connection, base.table_name, joins)
1139
+ @eager_loading = eager_loading # (Unused in Rails 5.0)
1140
+ else # Rails 4.2
1141
+ @alias_tracker = araat.create(base.connection, joins)
1142
+ @alias_tracker.aliased_table_for(base, base.table_name) # Updates the count for base.table_name to 1
1143
+ end
1089
1144
  tree = self.class.make_tree associations
1090
1145
 
1091
1146
  # Provide a way to find the original relation that this tree is being used for
@@ -1098,7 +1153,7 @@ ActiveSupport.on_load(:active_record) do
1098
1153
  @join_root.children.each { |child| construct_tables! @join_root, child }
1099
1154
  end
1100
1155
 
1101
- else # For ActiveRecord 5.0 - 7.1
1156
+ else # For ActiveRecord 5.2 - 7.1
1102
1157
 
1103
1158
  def initialize(base, table, associations, join_type = nil)
1104
1159
  tree = self.class.make_tree associations
@@ -1245,13 +1300,13 @@ module ActiveRecord
1245
1300
 
1246
1301
  if private_instance_methods.include?(:build_join_query)
1247
1302
  alias _brick_build_join_query build_join_query
1248
- def build_join_query(manager, buckets, *args)
1303
+ def build_join_query(manager, buckets, *args) # , **kwargs)
1249
1304
  # %%% Better way to bring relation into the mix
1250
1305
  if (aj = buckets.fetch(:association_join, nil))
1251
1306
  aj.instance_variable_set(:@relation, self)
1252
1307
  end
1253
1308
 
1254
- _brick_build_join_query(manager, buckets, *args)
1309
+ _brick_build_join_query(manager, buckets, *args) # , **kwargs)
1255
1310
  end
1256
1311
 
1257
1312
  else
@@ -1433,4 +1488,85 @@ if Gem::Specification.all_names.any? { |g| g.start_with?('ransack-') }
1433
1488
  end
1434
1489
  end
1435
1490
 
1491
+ # Keyword arguments updates for Rails <= 5.2.x and Ruby >= 3.0
1492
+ if ActiveRecord.version < ::Gem::Version.new('6.0') && ruby_version >= ::Gem::Version.new('3.0')
1493
+ admsm = ActionDispatch::MiddlewareStack::Middleware
1494
+ admsm.class_exec do
1495
+ # redefine #build
1496
+ def build(app, **kwargs)
1497
+ # puts klass.name
1498
+ if args.length > 1 && args.last.is_a?(Hash)
1499
+ kwargs.merge!(args.pop)
1500
+ end
1501
+ # binding.pry if klass == ActionDispatch::Static # ActionDispatch::Reloader
1502
+ klass.new(app, *args, **kwargs, &block)
1503
+ end
1504
+ end
1505
+
1506
+ require 'active_model'
1507
+ require 'active_model/type'
1508
+ require 'active_model/type/value'
1509
+ class ActiveModel::Type::Value
1510
+ def initialize(*args, precision: nil, limit: nil, scale: nil)
1511
+ @precision = precision
1512
+ @scale = scale
1513
+ @limit = limit
1514
+ end
1515
+ end
1516
+
1517
+ if Object.const_defined?('I18n')
1518
+ module I18n::Base
1519
+ alias _brick_translate translate
1520
+ def translate(key = nil, *args, throw: false, raise: false, locale: nil, **options)
1521
+ options.merge!(args.pop) if args.length > 0 && args.last.is_a?(Hash)
1522
+ _brick_translate(key = nil, throw: false, raise: false, locale: nil, **options)
1523
+ end
1524
+ end
1525
+ end
1526
+
1527
+ module ActionController::RequestForgeryProtection
1528
+ private
1529
+
1530
+ # Creates the authenticity token for the current request.
1531
+ def form_authenticity_token(*args, form_options: {}) # :doc:
1532
+ form_options.merge!(args.pop) if args.length > 0 && args.last.is_a?(Hash)
1533
+ masked_authenticity_token(session, form_options: form_options)
1534
+ end
1535
+ end
1536
+
1537
+ module ActiveSupport
1538
+ class MessageEncryptor
1539
+ def encrypt_and_sign(value, *args, expires_at: nil, expires_in: nil, purpose: nil)
1540
+ encrypted = if method(:_encrypt).arity == 1
1541
+ _encrypt(value) # Rails <= 5.1
1542
+ else
1543
+ if args.length > 0 && args.last.is_a?(Hash)
1544
+ expires_at ||= args.last[:expires_at]
1545
+ expires_in ||= args.last[:expires_in]
1546
+ purpose ||= args.last[:purpose]
1547
+ end
1548
+ _encrypt(value, expires_at: expires_at, expires_in: expires_in, purpose: purpose)
1549
+ end
1550
+ verifier.generate(encrypted)
1551
+ end
1552
+ end
1553
+ if const_defined?('Messages')
1554
+ class Messages::Metadata
1555
+ def self.wrap(message, *args, expires_at: nil, expires_in: nil, purpose: nil)
1556
+ if args.length > 0 && args.last.is_a?(Hash)
1557
+ expires_at ||= args.last[:expires_at]
1558
+ expires_in ||= args.last[:expires_in]
1559
+ purpose ||= args.last[:purpose]
1560
+ end
1561
+ if expires_at || expires_in || purpose
1562
+ JSON.encode new(encode(message), pick_expiry(expires_at, expires_in), purpose)
1563
+ else
1564
+ message
1565
+ end
1566
+ end
1567
+ end
1568
+ end
1569
+ end
1570
+ end
1571
+
1436
1572
  require 'brick/extensions'
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.101
4
+ version: 1.0.102
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-12-17 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.42.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: mysql2
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.5'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.5'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: pg
169
183
  requirement: !ruby/object:Gem::Requirement