gettext_i18n_rails 1.3.2 → 1.4.0

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
  SHA1:
3
- metadata.gz: db41b40bff533c0a267a7eacc47e964ab493ea54
4
- data.tar.gz: 2160bc505b80c1b6826df6cb647c0010a5abe641
3
+ metadata.gz: 6309ef5328491946dd08f1313790497b950be538
4
+ data.tar.gz: 5f3c4e53c3eb4ac52abf33c4493b89c238ffc87c
5
5
  SHA512:
6
- metadata.gz: 5e39ef272d3f4e7560ff45d3d82ea040fa16dca5890ddb7ca1af6e642d32598243fd376d1333fd34aa28dbef1eb74dbc08822ccc72e00d59e8d227dee6856f4c
7
- data.tar.gz: e516e951baafd95d7b04b19156845faccd339746b1824ca1f85050adf0f7e1ad6c4894dd2993343e3583ee6e7dda1e00d03bc66b343cc40bbd7e9ee1960a08a8
6
+ metadata.gz: 4f278a1105f2404e041ca2d13013f832a28d4fe5f77f4cbc2f3b58ef8b8a62ec61da5b81410a250b56b0ddc7d0a8ef288ff26540e8cfac093f6acca72d064e70
7
+ data.tar.gz: 6160b00c0cc1d850fe031cf1f4d56dc2d32f734d134da5ae9f8eaaa740f346b6ccd7f09bb85271287f5fd246634f0191f75316190b14f360684a9e65b124ee00
@@ -17,7 +17,15 @@ module ActiveModel
17
17
  def inheritance_tree_root(aclass)
18
18
  return aclass unless aclass.respond_to?(:base_class)
19
19
  base = aclass.base_class
20
- base.superclass.abstract_class? ? base.superclass : base
20
+ if base.superclass.abstract_class?
21
+ if defined?(::ApplicationRecord) && base.superclass == ApplicationRecord
22
+ base
23
+ else
24
+ base.superclass
25
+ end
26
+ else
27
+ base
28
+ end
21
29
  end
22
30
 
23
31
  def humanize_class_name(name=nil)
@@ -42,15 +42,16 @@ module GettextI18nRails
42
42
  end
43
43
 
44
44
  def initialize
45
- @existing_tables = ::ActiveRecord::Base.connection.tables
45
+ connection = ::ActiveRecord::Base.connection
46
+ @existing_tables = (Rails::VERSION::MAJOR >= 5 ? connection.data_sources : connection.tables)
46
47
  end
47
48
 
48
- # Rails < 3.0 doesn't have DescendantsTracker.
49
+ # Rails < 3.0 doesn't have DescendantsTracker.
49
50
  # Instead of iterating over ObjectSpace (slow) the decision was made NOT to support
50
51
  # class hierarchies with abstract base classes in Rails 2.x
51
52
  def model_attributes(model, ignored_tables, ignored_cols)
52
53
  return [] if model.abstract_class? && Rails::VERSION::MAJOR < 3
53
-
54
+
54
55
  if model.abstract_class?
55
56
  model.direct_descendants.reject {|m| ignored?(m.table_name, ignored_tables)}.inject([]) do |attrs, m|
56
57
  attrs.push(model_attributes(m, ignored_tables, ignored_cols)).flatten.uniq
@@ -63,9 +64,17 @@ module GettextI18nRails
63
64
  end
64
65
 
65
66
  def models
66
- if Rails::VERSION::MAJOR > 2
67
+ if Rails::VERSION::MAJOR >= 3
67
68
  Rails.application.eager_load! # make sure that all models are loaded so that direct_descendants works
68
- ::ActiveRecord::Base.direct_descendants
69
+ descendants = ::ActiveRecord::Base.direct_descendants
70
+
71
+ # In rails 5+ user models are supposed to inherit from ApplicationRecord
72
+ if defined?(::ApplicationRecord)
73
+ descendants += ApplicationRecord.direct_descendants
74
+ descendants.delete ApplicationRecord
75
+ end
76
+
77
+ descendants
69
78
  else
70
79
  ::ActiveRecord::Base.connection.tables \
71
80
  .map { |t| table_name_to_namespaced_model(t) } \
@@ -1,3 +1,3 @@
1
1
  module GettextI18nRails
2
- Version = VERSION = '1.3.2'
2
+ Version = VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext_i18n_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_gettext