mobility 1.3.0.rc2 → 1.3.0.rc3

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: 6f693f3dcc0f7b22ea963e01dedcfab909f659f39441e16894e0490f5ed99024
4
- data.tar.gz: 444117b04d4d0934c854384e3c52119a43f5c2772202c893f15cd8a8ca8b1651
3
+ metadata.gz: fd0b53980f62d9538827053f6e08b8ffd287d44a7a4aa87602c5d85e87bf30fc
4
+ data.tar.gz: 540af4290175ec08b109a8cc0e783c1a634c66fe87bf97fd014d5c5a0f78b79c
5
5
  SHA512:
6
- metadata.gz: 7fde354db46b03dfad8efaf22f542c4b9850cda464e562ea31309c311cec27e6f1a400d1842660cd103dba13f22a48b342feccf46bb22249d34295673666f176
7
- data.tar.gz: 57ee5c44f0bb58d25a97f7de1f854ef3252117f89e273e39e4feba3ed35ee6443356d6488cdab992d4cd92160a8f72a84d6064c3e24aa105afd6479b000db82d
6
+ metadata.gz: 25fc7f6a40125020f7425691a3d183a290bfaa3381594d1ad218a924797a0329f76ca39494742f380a3310fbe9d3c879849e366de20bd695219b247c90161d17
7
+ data.tar.gz: 8b02e9620070979a64e71d2774495a1be0054e92180116e4e40790575d05faff38fb78001ab460581de2524598af3823f312734b67804d2debe1de428737801a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,9 +2,22 @@
2
2
 
3
3
  ## 1.3
4
4
 
5
+ ### 1.3.0.rc3
6
+
7
+ - Don't try to load generators if Rails is loaded but AR is not
8
+ ([#627](https://github.com/shioyama/mobility/pull/627)), thanks
9
+ [flop](https://github.com/flop)!
10
+ - Allow compound foreign keys
11
+ ([#632](https://github.com/shioyama/mobility/pull/632)), thanks
12
+ [mival](https://github.com/mival)!
13
+ - Fix active model `*_previously_changed?` and active record
14
+ `will_save_change_to_*?` and `saved_change_to_*?` dirty methods to accept
15
+ kwargs ([#639](https://github.com/shioyama/mobility/pull/639)) thanks
16
+ [doits](https://github.com/doits)!
17
+
5
18
  ### 1.3.0.rc2
6
19
 
7
- - Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 3.2)
20
+ - Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 7.1)
8
21
  ([#617](https://github.com/shioyama/mobility/pull/617))
9
22
 
10
23
  ### 1.3.0.rc1
data/README.md CHANGED
@@ -4,7 +4,6 @@ Mobility
4
4
  [![Gem Version](https://badge.fury.io/rb/mobility.svg)][gem]
5
5
  [![Build Status](https://github.com/shioyama/mobility/workflows/CI/badge.svg)][actions]
6
6
  [![Code Climate](https://api.codeclimate.com/v1/badges/72200f2b00c339ec4537/maintainability.svg)][codeclimate]
7
- [![Gitter Chat](https://badges.gitter.im/mobility-ruby/mobility.svg)](https://gitter.im/mobility-ruby/mobility)
8
7
 
9
8
  [gem]: https://rubygems.org/gems/mobility
10
9
  [actions]: https://github.com/shioyama/mobility/actions
@@ -55,17 +54,13 @@ Installation
55
54
  Add this line to your application's Gemfile:
56
55
 
57
56
  ```ruby
58
- gem 'mobility', '~> 1.3.0.rc2'
57
+ gem 'mobility', '~> 1.3.0.rc3'
59
58
  ```
60
59
 
61
60
  ### ActiveRecord (Rails)
62
61
 
63
62
  Requirements:
64
- - ActiveRecord >= 5.0 (including 6.x)
65
-
66
- (Support for most backends and features is also supported with
67
- ActiveRecord/Rails 4.2, but there are some tests still failing. To see exactly
68
- what might not work, check pending specs in Rails 4.2 builds.)
63
+ - ActiveRecord >= 6.1
69
64
 
70
65
  To translate attributes on a model, extend `Mobility`, then call `translates`
71
66
  passing in one or more attributes as well as a hash of options (see below).
@@ -109,7 +109,13 @@ columns to that table.
109
109
  options[:association_name] = :translations
110
110
  options[:subclass_name] ||= :Translation
111
111
  end
112
- %i[foreign_key association_name subclass_name table_name].each { |key| options[key] = options[key].to_sym }
112
+ %i[foreign_key association_name subclass_name table_name].each { |key|
113
+ if options[key].is_a?(Enumerable)
114
+ options[key] = options[key].map!(&:to_sym)
115
+ else
116
+ options[key] = options[key].to_sym
117
+ end
118
+ }
113
119
  end
114
120
  # @!endgroup
115
121
 
@@ -119,6 +119,14 @@ the ActiveRecord dirty plugin for more information.
119
119
  class HandlerMethodsBuilder < Module
120
120
  attr_reader :klass
121
121
 
122
+ PATTERNS_WITH_KWARGS =
123
+ %w[
124
+ %s_changed?
125
+ %s_previously_changed?
126
+ will_save_change_to_%s?
127
+ saved_change_to_%s?
128
+ ].freeze
129
+
122
130
  # @param [Class] klass Dirty class to mimic
123
131
  def initialize(klass)
124
132
  @klass = klass
@@ -135,7 +143,7 @@ the ActiveRecord dirty plugin for more information.
135
143
  public_patterns.each do |pattern|
136
144
  method_name = pattern % 'attribute'
137
145
 
138
- kwargs = pattern == '%s_changed?' ? ', **kwargs' : ''
146
+ kwargs = PATTERNS_WITH_KWARGS.include?(pattern) ? ', **kwargs' : ''
139
147
  module_eval <<-EOM, __FILE__, __LINE__ + 1
140
148
  def #{method_name}(attr_name, *rest#{kwargs})
141
149
  if (mutations_from_mobility.attribute_changed?(attr_name) ||
@@ -298,8 +306,10 @@ the ActiveRecord dirty plugin for more information.
298
306
  (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
299
307
  end
300
308
 
301
- def attribute_previously_changed?(attr_name)
302
- previous_changes.include?(attr_name)
309
+ def attribute_previously_changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
310
+ previous_changes.include?(attr_name) &&
311
+ (OPTION_NOT_GIVEN == from || attribute_previous_change(attr_name).first == from) &&
312
+ (OPTION_NOT_GIVEN == to || attribute_previous_change(attr_name).second == to)
303
313
  end
304
314
 
305
315
  def attribute_was(attr_name)
@@ -9,7 +9,7 @@ module Mobility
9
9
  MAJOR = 1
10
10
  MINOR = 3
11
11
  TINY = 0
12
- PRE = "rc2"
12
+ PRE = "rc3"
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
15
15
  end
data/lib/mobility.rb CHANGED
@@ -90,7 +90,7 @@ module Mobility
90
90
  CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
91
91
  private_constant :CALL_COMPILABLE_REGEXP
92
92
 
93
- require "rails/generators/mobility/generators" if defined?(Rails)
93
+ require "rails/generators/mobility/generators" if defined?(Rails) && defined?(ActiveRecord)
94
94
 
95
95
  class << self
96
96
  def extended(model_class)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.rc2
4
+ version: 1.3.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -12,30 +12,30 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
14
14
  czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTIzMDMyODA3MTQzNVoXDTI0MDMyNzA3MTQzNVowPzEOMAwGA1UEAwwFY2hy
15
+ MB4XDTI0MDMzMTA4NTQyOFoXDTI1MDMzMTA4NTQyOFowPzEOMAwGA1UEAwwFY2hy
16
16
  aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAJI6uJ3SQZs7gaYR4nFb
18
- yKG+ZHDMoAvrYHPp5hb3ssueoniFtfV1SOh2QOm3AfdA4XIiUco1NAepYkp+zEIT
19
- sCUKWkYe8uOwvpdTBrO6JbEfFw0/2ewkCWreN/hfFjOXqZIieJXEHeScrzbU0w/6
20
- /oa3rsiN91ED1qaQqRU7K9pPuhuOnKrZSzdTDpbwbBn4jK2j2BQ2/yRlX6FObOWa
21
- 4gpyFpr0jU0rpk38UOiHS9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KZwlG0cX8UwG482Xt
33
+ WJSXNylIIbzRndVjbVdGVhhcyjnswfu1qJpl+0YlbAdHJVsd8Ux8TOXEPFMv5wz9
34
+ wXhTYFvkOuleWf/45E5f8BtT1iqsH2w3P2Cfy+yOo2aReAVSeR12YDCuV0q6RjTD
35
+ 3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
36
+ tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
37
37
  -----END CERTIFICATE-----
38
- date: 2024-03-20 00:00:00.000000000 Z
38
+ date: 2024-03-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: request_store
metadata.gz.sig CHANGED
Binary file