goldiloader 1.0.1 → 2.0.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 +4 -4
- data/lib/goldiloader/active_record_patches.rb +121 -118
- data/lib/goldiloader/association_info.rb +20 -105
- data/lib/goldiloader/association_loader.rb +1 -25
- data/lib/goldiloader/association_options.rb +2 -20
- data/lib/goldiloader/compatibility.rb +4 -51
- data/lib/goldiloader/version.rb +1 -1
- metadata +18 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c786bf07ce1fedb7741246eda75430f8360617e
|
4
|
+
data.tar.gz: 855321310698182f6016a12556c9010bf2f8075c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea207299074113890d1d278f5f83681fdb542b5b68b6006ce62eb58857c421b00181c5ba8a6dcd6c99e5043667b8dc710c189cbb6c5ad8805f99565143183b2
|
7
|
+
data.tar.gz: ca685d4a21ddcdfde6bc0bad6dc3894cdc7bc6cc850a09388014c462a9c3fdd63877f8469c90df69cd90138ca8dbb2c175b2df61f33fa427352c09c234e2b074
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Goldiloader
|
4
|
-
module
|
4
|
+
module BasePatch
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
8
|
attr_writer :auto_include_context
|
9
|
+
|
10
|
+
class << self
|
11
|
+
delegate :auto_include, to: :all
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def initialize_copy(other)
|
@@ -22,158 +26,157 @@ module Goldiloader
|
|
22
26
|
super
|
23
27
|
end
|
24
28
|
end
|
25
|
-
|
29
|
+
::ActiveRecord::Base.include(::Goldiloader::BasePatch)
|
26
30
|
|
27
|
-
|
31
|
+
module RelationPatch
|
32
|
+
def exec_queries
|
33
|
+
return super if loaded? || !auto_include_value
|
28
34
|
|
29
|
-
|
35
|
+
models = super
|
36
|
+
Goldiloader::AutoIncludeContext.register_models(models, eager_load_values)
|
37
|
+
models
|
38
|
+
end
|
30
39
|
|
31
|
-
|
32
|
-
|
40
|
+
def auto_include(auto_include = true)
|
41
|
+
spawn.auto_include!(auto_include)
|
42
|
+
end
|
33
43
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
44
|
+
def auto_include!(auto_include = true)
|
45
|
+
self.auto_include_value = auto_include
|
46
|
+
self
|
47
|
+
end
|
38
48
|
|
39
|
-
|
40
|
-
|
49
|
+
def auto_include_value
|
50
|
+
# Note: Don't use get_value because that doesn't work properly with defaulting boolean values
|
51
|
+
@values.fetch(:auto_include, true)
|
52
|
+
end
|
41
53
|
|
42
|
-
|
54
|
+
def auto_include_value=(value)
|
55
|
+
if Goldiloader::Compatibility.rails_4?
|
56
|
+
raise ::ActiveRecord::Relation::ImmutableRelation if @loaded
|
57
|
+
check_cached_relation
|
58
|
+
@values[:auto_include] = value
|
59
|
+
elsif Goldiloader::Compatibility.rails_5_0?
|
60
|
+
assert_mutability!
|
61
|
+
@values[:auto_include] = value
|
62
|
+
else
|
63
|
+
set_value(:auto_include, value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
::ActiveRecord::Relation.prepend(::Goldiloader::RelationPatch)
|
43
68
|
|
44
|
-
|
45
|
-
|
46
|
-
self.default_fully_load = false
|
69
|
+
module MergerPatch
|
70
|
+
private
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
72
|
+
def merge_single_values
|
73
|
+
relation.auto_include_value = other.auto_include_value
|
74
|
+
super
|
75
|
+
end
|
52
76
|
end
|
77
|
+
ActiveRecord::Relation::Merger.prepend(::Goldiloader::MergerPatch)
|
53
78
|
|
54
|
-
|
55
|
-
|
56
|
-
|
79
|
+
module AssociationPatch
|
80
|
+
extend ActiveSupport::Concern
|
81
|
+
|
82
|
+
included do
|
83
|
+
class_attribute :default_fully_load
|
84
|
+
self.default_fully_load = false
|
85
|
+
end
|
57
86
|
|
58
|
-
|
87
|
+
def auto_include?
|
88
|
+
# We only auto include associations that don't have in-memory changes since the
|
89
|
+
# Rails association Preloader clobbers any in-memory changes
|
90
|
+
!loaded? && target.blank? && eager_loadable?
|
91
|
+
end
|
92
|
+
|
93
|
+
def fully_load?
|
94
|
+
!loaded? && options.fetch(:fully_load) { self.class.default_fully_load }
|
95
|
+
end
|
59
96
|
|
60
|
-
|
61
|
-
|
62
|
-
|
97
|
+
private
|
98
|
+
|
99
|
+
def eager_loadable?
|
100
|
+
association_info = Goldiloader::AssociationInfo.new(self)
|
101
|
+
!association_info.limit? &&
|
63
102
|
!association_info.offset? &&
|
64
103
|
!association_info.group? &&
|
65
104
|
!association_info.from? &&
|
66
|
-
!association_info.
|
67
|
-
|
68
|
-
|
69
|
-
!association_info.instance_dependent?
|
70
|
-
end
|
105
|
+
!association_info.instance_dependent? &&
|
106
|
+
association_info.auto_include?
|
107
|
+
end
|
71
108
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
109
|
+
def load_with_auto_include
|
110
|
+
if loaded? && !stale_target?
|
111
|
+
target
|
112
|
+
elsif auto_include?
|
113
|
+
Goldiloader::AssociationLoader.load(owner, reflection.name)
|
114
|
+
target
|
115
|
+
else
|
116
|
+
yield
|
117
|
+
end
|
80
118
|
end
|
81
119
|
end
|
120
|
+
::ActiveRecord::Associations::Association.include(::Goldiloader::AssociationPatch)
|
82
121
|
|
83
|
-
|
84
|
-
|
85
|
-
ActiveRecord::Associations::SingularAssociation.class_eval do
|
86
|
-
|
87
|
-
private
|
122
|
+
module SingularAssociationPatch
|
123
|
+
private
|
88
124
|
|
89
|
-
|
90
|
-
|
125
|
+
def find_target(*args)
|
126
|
+
load_with_auto_include { super }
|
127
|
+
end
|
91
128
|
end
|
129
|
+
::ActiveRecord::Associations::SingularAssociation.prepend(::Goldiloader::SingularAssociationPatch)
|
92
130
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
[:first, :second, :third, :fourth, :fifth, :last, :size, :ids_reader, :empty?].each do |method|
|
99
|
-
# Some of these methods were added in Rails 4
|
100
|
-
next unless method_defined?(method)
|
101
|
-
|
102
|
-
aliased_target, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
|
103
|
-
define_method("#{aliased_target}_with_fully_load#{punctuation}") do |*args, &block|
|
104
|
-
load_target if fully_load?
|
105
|
-
send("#{aliased_target}_without_fully_load#{punctuation}", *args, &block)
|
131
|
+
module CollectionAssociationPatch
|
132
|
+
# Force these methods to load the entire association for fully_load associations
|
133
|
+
association_methods = [:size, :ids_reader, :empty?]
|
134
|
+
if Goldiloader::Compatibility::ACTIVE_RECORD_VERSION < ::Gem::Version.new('5.1')
|
135
|
+
association_methods.concat([:first, :second, :third, :fourth, :fifth, :last])
|
106
136
|
end
|
107
137
|
|
108
|
-
|
109
|
-
|
138
|
+
association_methods.each do |method|
|
139
|
+
define_method(method) do |*args, &block|
|
140
|
+
load_target if fully_load?
|
141
|
+
super(*args, &block)
|
142
|
+
end
|
143
|
+
end
|
110
144
|
|
111
|
-
|
145
|
+
def load_target(*args)
|
146
|
+
load_with_auto_include { super }
|
147
|
+
end
|
112
148
|
|
113
|
-
|
114
|
-
|
149
|
+
if Goldiloader::Compatibility::ACTIVE_RECORD_VERSION >= ::Gem::Version.new('5.1')
|
150
|
+
def find_from_target?
|
151
|
+
fully_load? || super
|
152
|
+
end
|
153
|
+
end
|
115
154
|
end
|
155
|
+
::ActiveRecord::Associations::CollectionAssociation.prepend(::Goldiloader::CollectionAssociationPatch)
|
116
156
|
|
117
|
-
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
[ActiveRecord::Associations::HasManyThroughAssociation, ActiveRecord::Associations::HasOneThroughAssociation].each do |klass|
|
122
|
-
klass.class_eval do
|
157
|
+
module ThroughAssociationPatch
|
123
158
|
def auto_include?
|
124
159
|
# Only auto include through associations if the target association is auto-loadable
|
125
160
|
through_association = owner.association(through_reflection.name)
|
126
161
|
through_association.auto_include? && super
|
127
162
|
end
|
128
163
|
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
# association
|
144
|
-
if Goldiloader::Compatibility::ACTIVE_RECORD_VERSION >= ::Gem::Version.new('4.1')
|
145
|
-
ActiveRecord::Associations::ClassMethods.class_eval do
|
146
|
-
|
147
|
-
def has_and_belongs_to_many_with_auto_include_option(name, scope = nil, options = {}, &extension)
|
148
|
-
if scope.is_a?(Hash)
|
149
|
-
options = scope
|
150
|
-
scope = nil
|
164
|
+
::ActiveRecord::Associations::HasManyThroughAssociation.prepend(::Goldiloader::ThroughAssociationPatch)
|
165
|
+
::ActiveRecord::Associations::HasOneThroughAssociation.prepend(::Goldiloader::ThroughAssociationPatch)
|
166
|
+
|
167
|
+
module CollectionProxyPatch
|
168
|
+
# The CollectionProxy just forwards exists? to the underlying scope so we need to intercept this and
|
169
|
+
# force it to use size which handles fully_load properly.
|
170
|
+
def exists?(*args)
|
171
|
+
# We don't fully_load the association when arguments are passed to exists? since Rails always
|
172
|
+
# pushes this query into the database without any caching (and it likely not a common
|
173
|
+
# scenario worth optimizing).
|
174
|
+
if args.empty? && @association.fully_load?
|
175
|
+
size > 0
|
176
|
+
else
|
177
|
+
scope.exists?(*args)
|
151
178
|
end
|
152
|
-
|
153
|
-
result = has_and_belongs_to_many_without_auto_include_option(name, scope, options, &extension)
|
154
|
-
if options.include?(:auto_include)
|
155
|
-
_reflect_on_association(name).options[:auto_include] = options[:auto_include]
|
156
|
-
end
|
157
|
-
result
|
158
|
-
end
|
159
|
-
|
160
|
-
Goldiloader::Compatibility.alias_method_chain self, :has_and_belongs_to_many, :auto_include_option
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# The CollectionProxy just forwards exists? to the underlying scope so we need to intercept this and
|
165
|
-
# force it to use size which handles fully_load properly.
|
166
|
-
ActiveRecord::Associations::CollectionProxy.class_eval do
|
167
|
-
def exists?(*args)
|
168
|
-
# We don't fully_load the association when arguments are passed to exists? since Rails always
|
169
|
-
# pushes this query into the database without any caching (and it likely not a common
|
170
|
-
# scenario worth optimizing).
|
171
|
-
if args.empty? && @association.fully_load?
|
172
|
-
size > 0
|
173
|
-
elsif Goldiloader::Compatibility::RAILS_3
|
174
|
-
scoped.exists?(*args)
|
175
|
-
else
|
176
|
-
scope.exists?(*args)
|
177
179
|
end
|
178
180
|
end
|
181
|
+
::ActiveRecord::Associations::CollectionProxy.prepend(::Goldiloader::CollectionProxyPatch)
|
179
182
|
end
|
@@ -7,119 +7,34 @@ module Goldiloader
|
|
7
7
|
@association = association
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
Goldiloader::Compatibility.association_finder_sql_enabled? &&
|
12
|
-
association_options[:finder_sql].present?
|
13
|
-
end
|
14
|
-
|
15
|
-
if ActiveRecord::VERSION::MAJOR >= 4
|
16
|
-
delegate :association_scope, :reflection, to: :@association
|
17
|
-
|
18
|
-
def read_only?
|
19
|
-
association_scope && association_scope.readonly_value.present?
|
20
|
-
end
|
21
|
-
|
22
|
-
def offset?
|
23
|
-
association_scope && association_scope.offset_value.present?
|
24
|
-
end
|
25
|
-
|
26
|
-
def limit?
|
27
|
-
association_scope && association_scope.limit_value.present?
|
28
|
-
end
|
29
|
-
|
30
|
-
def from?
|
31
|
-
if ActiveRecord::VERSION::MAJOR >= 5
|
32
|
-
association_scope && association_scope.from_clause.present?
|
33
|
-
else
|
34
|
-
association_scope && association_scope.from_value.present?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def group?
|
39
|
-
association_scope && association_scope.group_values.present?
|
40
|
-
end
|
41
|
-
|
42
|
-
def joins?
|
43
|
-
return false unless association_scope
|
44
|
-
|
45
|
-
num_joins = association_scope.joins_values.size
|
46
|
-
if ActiveRecord::VERSION::MAJOR >= 5
|
47
|
-
num_joins += association_scope.left_joins_values.size + association_scope.left_outer_joins.size
|
48
|
-
end
|
49
|
-
# Yuck - Through associations will always have a join for *each* 'through' table
|
50
|
-
num_joins - num_through_joins > 0
|
51
|
-
end
|
52
|
-
|
53
|
-
def uniq?
|
54
|
-
association_scope && association_scope.uniq_value
|
55
|
-
end
|
56
|
-
|
57
|
-
def instance_dependent?
|
58
|
-
reflection.scope.present? && reflection.scope.arity > 0
|
59
|
-
end
|
60
|
-
|
61
|
-
def unscope?
|
62
|
-
Goldiloader::Compatibility.unscope_query_method_enabled? &&
|
63
|
-
association_scope &&
|
64
|
-
association_scope.unscope_values.present?
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def num_through_joins
|
70
|
-
association = @association
|
71
|
-
count = 0
|
72
|
-
while association.is_a?(ActiveRecord::Associations::ThroughAssociation)
|
73
|
-
count += 1
|
74
|
-
association = association.owner.association(association.through_reflection.name)
|
75
|
-
end
|
76
|
-
count
|
77
|
-
end
|
78
|
-
else
|
79
|
-
def read_only?
|
80
|
-
association_options[:readonly].present?
|
81
|
-
end
|
82
|
-
|
83
|
-
def offset?
|
84
|
-
association_options[:offset].present?
|
85
|
-
end
|
86
|
-
|
87
|
-
def limit?
|
88
|
-
association_options[:limit].present?
|
89
|
-
end
|
90
|
-
|
91
|
-
def from?
|
92
|
-
false
|
93
|
-
end
|
94
|
-
|
95
|
-
def group?
|
96
|
-
association_options[:group].present?
|
97
|
-
end
|
10
|
+
delegate :association_scope, :reflection, to: :@association
|
98
11
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
12
|
+
def offset?
|
13
|
+
association_scope && association_scope.offset_value.present?
|
14
|
+
end
|
103
15
|
|
104
|
-
|
105
|
-
|
106
|
-
|
16
|
+
def limit?
|
17
|
+
association_scope && association_scope.limit_value.present?
|
18
|
+
end
|
107
19
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
20
|
+
def auto_include?
|
21
|
+
association_scope.nil? || association_scope.auto_include_value
|
22
|
+
end
|
112
23
|
|
113
|
-
|
114
|
-
|
115
|
-
|
24
|
+
def from?
|
25
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
26
|
+
association_scope && association_scope.from_clause.present?
|
27
|
+
else
|
28
|
+
association_scope && association_scope.from_value.present?
|
116
29
|
end
|
117
30
|
end
|
118
31
|
|
119
|
-
|
32
|
+
def group?
|
33
|
+
association_scope && association_scope.group_values.present?
|
34
|
+
end
|
120
35
|
|
121
|
-
def
|
122
|
-
|
36
|
+
def instance_dependent?
|
37
|
+
reflection.scope.present? && reflection.scope.arity > 0
|
123
38
|
end
|
124
39
|
end
|
125
40
|
end
|
@@ -10,36 +10,12 @@ module Goldiloader
|
|
10
10
|
end
|
11
11
|
|
12
12
|
eager_load(models, association_name)
|
13
|
-
|
14
|
-
# Workaround Rails #15853 for Rails < 4.2.0 by setting models read only
|
15
|
-
if read_only?(models, association_name)
|
16
|
-
associated_models = associated_models(models, association_name)
|
17
|
-
mark_read_only(associated_models)
|
18
|
-
end
|
19
13
|
end
|
20
14
|
|
21
15
|
private
|
22
16
|
|
23
17
|
def eager_load(models, association_name)
|
24
|
-
|
25
|
-
::ActiveRecord::Associations::Preloader.new.preload(models, [association_name])
|
26
|
-
else
|
27
|
-
::ActiveRecord::Associations::Preloader.new(models, [association_name]).run
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def mark_read_only(models)
|
32
|
-
models.each(&:readonly!)
|
33
|
-
end
|
34
|
-
|
35
|
-
def read_only?(models, association_name)
|
36
|
-
model = first_model_with_association(models, association_name)
|
37
|
-
if model.nil?
|
38
|
-
false
|
39
|
-
else
|
40
|
-
association_info = AssociationInfo.new(model.association(association_name))
|
41
|
-
association_info.read_only?
|
42
|
-
end
|
18
|
+
::ActiveRecord::Associations::Preloader.new.preload(models, [association_name])
|
43
19
|
end
|
44
20
|
|
45
21
|
def first_model_with_association(models, association_name)
|
@@ -4,7 +4,7 @@ module Goldiloader
|
|
4
4
|
module AssociationOptions
|
5
5
|
extend self
|
6
6
|
|
7
|
-
OPTIONS = [:
|
7
|
+
OPTIONS = [:fully_load].freeze
|
8
8
|
|
9
9
|
# This is only used in Rails 5+
|
10
10
|
module AssociationBuilderExtension
|
@@ -20,30 +20,12 @@ module Goldiloader
|
|
20
20
|
def register
|
21
21
|
if ::ActiveRecord::VERSION::MAJOR >= 5
|
22
22
|
ActiveRecord::Associations::Builder::Association.extensions << AssociationBuilderExtension
|
23
|
-
elsif ::ActiveRecord::VERSION::MAJOR >= 4
|
24
|
-
ActiveRecord::Associations::Builder::Association.valid_options.concat(OPTIONS)
|
25
23
|
else
|
26
|
-
|
27
|
-
# to register the valid option for each one.
|
28
|
-
collection_association_classes.each do |assoc_class|
|
29
|
-
assoc_class.valid_options.concat(OPTIONS)
|
30
|
-
end
|
24
|
+
ActiveRecord::Associations::Builder::Association.valid_options.concat(OPTIONS)
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
34
28
|
private
|
35
|
-
|
36
|
-
def collection_association_classes
|
37
|
-
# Association.descendants doesn't work well with lazy classloading :(
|
38
|
-
[
|
39
|
-
ActiveRecord::Associations::Builder::Association,
|
40
|
-
ActiveRecord::Associations::Builder::BelongsTo,
|
41
|
-
ActiveRecord::Associations::Builder::HasAndBelongsToMany,
|
42
|
-
ActiveRecord::Associations::Builder::HasMany,
|
43
|
-
ActiveRecord::Associations::Builder::HasOne,
|
44
|
-
ActiveRecord::Associations::Builder::SingularAssociation
|
45
|
-
]
|
46
|
-
end
|
47
29
|
end
|
48
30
|
end
|
49
31
|
|
@@ -2,61 +2,14 @@
|
|
2
2
|
|
3
3
|
module Goldiloader
|
4
4
|
module Compatibility
|
5
|
-
|
6
5
|
ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING)
|
7
|
-
RAILS_3 = ACTIVE_RECORD_VERSION < ::Gem::Version.new('4')
|
8
|
-
MASS_ASSIGNMENT_SECURITY = RAILS_3 || defined?(::ActiveRecord::MassAssignmentSecurity)
|
9
|
-
ASSOCIATION_FINDER_SQL = ACTIVE_RECORD_VERSION < ::Gem::Version.new('4.1')
|
10
|
-
UNSCOPE_QUERY_METHOD = ACTIVE_RECORD_VERSION >= ::Gem::Version.new('4.1')
|
11
|
-
JOINS_EAGER_LOADABLE = ACTIVE_RECORD_VERSION >= ::Gem::Version.new('4.2')
|
12
|
-
UNSCOPED_EAGER_LOADABLE = ACTIVE_RECORD_VERSION >= ::Gem::Version.new('4.1.9')
|
13
|
-
|
14
|
-
def self.mass_assignment_security_enabled?
|
15
|
-
MASS_ASSIGNMENT_SECURITY
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.association_finder_sql_enabled?
|
19
|
-
ASSOCIATION_FINDER_SQL
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.unscope_query_method_enabled?
|
23
|
-
UNSCOPE_QUERY_METHOD
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.joins_eager_loadable?
|
27
|
-
# Associations with joins were not eager loadable prior to Rails 4.2 due to
|
28
|
-
# https://github.com/rails/rails/pull/17678
|
29
|
-
JOINS_EAGER_LOADABLE
|
30
|
-
end
|
31
6
|
|
32
|
-
def self.
|
33
|
-
|
34
|
-
# See https://github.com/rails/rails/issues/11036.
|
35
|
-
UNSCOPED_EAGER_LOADABLE
|
7
|
+
def self.rails_4?
|
8
|
+
::ActiveRecord::VERSION::MAJOR == 4
|
36
9
|
end
|
37
10
|
|
38
|
-
|
39
|
-
|
40
|
-
def self.alias_method_chain(klass, target, feature)
|
41
|
-
# Strip out punctuation on predicates, bang or writer methods since
|
42
|
-
# e.g. target?_without_feature is not a valid method name.
|
43
|
-
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
44
|
-
yield(aliased_target, punctuation) if block_given?
|
45
|
-
|
46
|
-
with_method = "#{aliased_target}_with_#{feature}#{punctuation}"
|
47
|
-
without_method = "#{aliased_target}_without_#{feature}#{punctuation}"
|
48
|
-
|
49
|
-
klass.send(:alias_method, without_method, target)
|
50
|
-
klass.send(:alias_method, target, with_method)
|
51
|
-
|
52
|
-
case
|
53
|
-
when klass.public_method_defined?(without_method)
|
54
|
-
klass.send(:public, target)
|
55
|
-
when klass.protected_method_defined?(without_method)
|
56
|
-
klass.send(:protected, target)
|
57
|
-
when klass.private_method_defined?(without_method)
|
58
|
-
klass.send(:private, target)
|
59
|
-
end
|
11
|
+
def self.rails_5_0?
|
12
|
+
::ActiveRecord::VERSION::MAJOR == 5 && ::ActiveRecord::VERSION::MINOR == 0
|
60
13
|
end
|
61
14
|
end
|
62
15
|
end
|
data/lib/goldiloader/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goldiloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
@@ -14,42 +14,30 @@ dependencies:
|
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.2'
|
20
|
-
- - "<"
|
17
|
+
- - '='
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 3.2.22.2
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.1'
|
26
|
+
version: 3.2.22.2
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: activesupport
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.2'
|
40
|
-
- - "<"
|
31
|
+
- - '='
|
41
32
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
33
|
+
version: 3.2.22.2
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
|
-
- -
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.2'
|
50
|
-
- - "<"
|
38
|
+
- - '='
|
51
39
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
40
|
+
version: 3.2.22.2
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: coveralls
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,30 +98,30 @@ dependencies:
|
|
110
98
|
name: simplecov
|
111
99
|
requirement: !ruby/object:Gem::Requirement
|
112
100
|
requirements:
|
113
|
-
- - "
|
101
|
+
- - ">="
|
114
102
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0
|
103
|
+
version: '0'
|
116
104
|
type: :development
|
117
105
|
prerelease: false
|
118
106
|
version_requirements: !ruby/object:Gem::Requirement
|
119
107
|
requirements:
|
120
|
-
- - "
|
108
|
+
- - ">="
|
121
109
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0
|
110
|
+
version: '0'
|
123
111
|
- !ruby/object:Gem::Dependency
|
124
112
|
name: mime-types
|
125
113
|
requirement: !ruby/object:Gem::Requirement
|
126
114
|
requirements:
|
127
|
-
- - "
|
115
|
+
- - ">="
|
128
116
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
117
|
+
version: '0'
|
130
118
|
type: :development
|
131
119
|
prerelease: false
|
132
120
|
version_requirements: !ruby/object:Gem::Requirement
|
133
121
|
requirements:
|
134
|
-
- - "
|
122
|
+
- - ">="
|
135
123
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
124
|
+
version: '0'
|
137
125
|
- !ruby/object:Gem::Dependency
|
138
126
|
name: sqlite3
|
139
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
164
|
requirements:
|
177
165
|
- - ">="
|
178
166
|
- !ruby/object:Gem::Version
|
179
|
-
version: '
|
167
|
+
version: '2.1'
|
180
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
169
|
requirements:
|
182
170
|
- - ">="
|