activeentity 0.0.1.beta15 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -3
- data/lib/active_entity.rb +1 -0
- data/lib/active_entity/attribute_assignment.rb +7 -11
- data/lib/active_entity/attribute_methods.rb +40 -50
- data/lib/active_entity/attribute_methods/before_type_cast.rb +5 -5
- data/lib/active_entity/attribute_methods/primary_key.rb +6 -8
- data/lib/active_entity/attribute_methods/query.rb +2 -6
- data/lib/active_entity/attribute_methods/read.rb +9 -10
- data/lib/active_entity/attribute_methods/write.rb +14 -21
- data/lib/active_entity/base.rb +0 -2
- data/lib/active_entity/{define_callbacks.rb → callbacks.rb} +5 -5
- data/lib/active_entity/core.rb +1 -0
- data/lib/active_entity/gem_version.rb +3 -3
- data/lib/active_entity/validations/uniqueness_on_active_record.rb +2 -13
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a48deda3be4192f640dfdf3feebc0152f65cd41eb7483e9c0d082a1565071227
|
4
|
+
data.tar.gz: 79b7877eee5cf2c3f9ae976533f15a0651b2cc0257174b2f7ea8a93034123212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 718bced85e2be2eb42ad37daca8ba3a9d1a1c63f3e91f6fedcea297c57abce9c596ab2bad681ecaad2d13b001edb7d695872021ebab5a57a954a9b63a409ebb5
|
7
|
+
data.tar.gz: 37eafc74002e3a8b5e4af2c017f070ba782c6b347dd40d92dcf25f867cf9be79b72fd4dba6e378766422741325e9e9df9c09dad43a35deb5e9ab1e496cdfb1f3
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ Supported Active Record validations:
|
|
65
65
|
|
66
66
|
#### `subset` validation
|
67
67
|
|
68
|
-
Because Active Entity supports array attribute, for some reason,
|
68
|
+
Because Active Entity supports array attribute, for some reason, you may want to test values of an array attribute are all included in a given set.
|
69
69
|
|
70
70
|
Active Entity provides `subset` validation to achieve that, it usage similar to `inclusion` or `exclusion`
|
71
71
|
|
@@ -76,9 +76,9 @@ class Steak < ActiveEntity::Base
|
|
76
76
|
end
|
77
77
|
```
|
78
78
|
|
79
|
-
#### `
|
79
|
+
#### `uniqueness_in_embeds` validation
|
80
80
|
|
81
|
-
Active Entity provides `
|
81
|
+
Active Entity provides `uniqueness_in_embeds` validation to test duplicate nesting virtual record.
|
82
82
|
|
83
83
|
Argument `key` is attribute name of nested model, it also supports multiple attributes by given an array.
|
84
84
|
|
@@ -101,6 +101,23 @@ class Book < ActiveEntity::Base
|
|
101
101
|
end
|
102
102
|
```
|
103
103
|
|
104
|
+
#### `uniqueness_in_active_record` validation
|
105
|
+
|
106
|
+
Active Entity provides `uniqueness_in_active_record` validation to test given `scope` doesn't present in ActiveRecord model.
|
107
|
+
|
108
|
+
The usage same as [uniqueness](https://guides.rubyonrails.org/active_record_validations.html#uniqueness) in addition you must give a AR model `class_name`
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
class Candidate < ActiveEntity::Base
|
112
|
+
attribute :name, :string
|
113
|
+
|
114
|
+
validates :name,
|
115
|
+
uniqueness_on_active_record: {
|
116
|
+
class_name: "Staff"
|
117
|
+
}
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
104
121
|
### Others
|
105
122
|
|
106
123
|
These Active Record feature also available in Active Entity
|
data/lib/active_entity.rb
CHANGED
@@ -6,29 +6,25 @@ module ActiveEntity
|
|
6
6
|
module AttributeAssignment
|
7
7
|
include ActiveModel::AttributeAssignment
|
8
8
|
|
9
|
-
def assign_attributes(attributes)
|
10
|
-
super(attributes.dup)
|
11
|
-
end
|
12
|
-
|
13
9
|
private
|
14
10
|
|
15
11
|
def _assign_attributes(attributes)
|
16
|
-
multi_parameter_attributes
|
17
|
-
nested_parameter_attributes = {}
|
12
|
+
multi_parameter_attributes = nested_parameter_attributes = nil
|
18
13
|
|
19
14
|
attributes.each do |k, v|
|
20
15
|
key = k.to_s
|
21
16
|
|
22
17
|
if key.include?("(")
|
23
|
-
multi_parameter_attributes[key] =
|
18
|
+
(multi_parameter_attributes ||= {})[key] = v
|
24
19
|
elsif v.is_a?(Hash)
|
25
|
-
nested_parameter_attributes[key] =
|
20
|
+
(nested_parameter_attributes ||= {})[key] = v
|
21
|
+
else
|
22
|
+
_assign_attribute(key, v)
|
26
23
|
end
|
27
24
|
end
|
28
|
-
super(attributes)
|
29
25
|
|
30
|
-
assign_nested_parameter_attributes(nested_parameter_attributes)
|
31
|
-
assign_multiparameter_attributes(multi_parameter_attributes)
|
26
|
+
assign_nested_parameter_attributes(nested_parameter_attributes) if nested_parameter_attributes
|
27
|
+
assign_multiparameter_attributes(multi_parameter_attributes) if multi_parameter_attributes
|
32
28
|
end
|
33
29
|
|
34
30
|
# Assign any deferred nested attributes after the base attributes have been set.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "mutex_m"
|
4
|
+
require "active_support/core_ext/enumerable"
|
4
5
|
|
5
6
|
module ActiveEntity
|
6
7
|
# = Active Entity Attribute Methods
|
@@ -26,6 +27,17 @@ module ActiveEntity
|
|
26
27
|
include Mutex_m
|
27
28
|
end
|
28
29
|
|
30
|
+
class << self
|
31
|
+
def dangerous_attribute_methods # :nodoc:
|
32
|
+
@dangerous_attribute_methods ||= (
|
33
|
+
Base.instance_methods +
|
34
|
+
Base.private_instance_methods -
|
35
|
+
Base.superclass.instance_methods -
|
36
|
+
Base.superclass.private_instance_methods
|
37
|
+
).map { |m| -m.to_s }.to_set.freeze
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
29
41
|
module ClassMethods
|
30
42
|
def inherited(child_class) #:nodoc:
|
31
43
|
child_class.initialize_generated_modules
|
@@ -95,7 +107,7 @@ module ActiveEntity
|
|
95
107
|
# A method name is 'dangerous' if it is already (re)defined by Active Entity, but
|
96
108
|
# not by any ancestors. (So 'puts' is not dangerous but 'save' is.)
|
97
109
|
def dangerous_attribute_method?(name) # :nodoc:
|
98
|
-
|
110
|
+
::ActiveEntity::AttributeMethods.dangerous_attribute_methods.include?(name.to_s)
|
99
111
|
end
|
100
112
|
|
101
113
|
def method_defined_within?(name, klass, superklass = klass.superclass) # :nodoc:
|
@@ -147,25 +159,40 @@ module ActiveEntity
|
|
147
159
|
# class Person < ActiveEntity::Base
|
148
160
|
# end
|
149
161
|
#
|
150
|
-
# Person.has_attribute?('name')
|
151
|
-
# Person.has_attribute?(
|
152
|
-
# Person.has_attribute?(:
|
162
|
+
# Person.has_attribute?('name') # => true
|
163
|
+
# Person.has_attribute?('new_name') # => true
|
164
|
+
# Person.has_attribute?(:age) # => true
|
165
|
+
# Person.has_attribute?(:nothing) # => false
|
153
166
|
def has_attribute?(attr_name)
|
154
|
-
|
167
|
+
attr_name = attr_name.to_s
|
168
|
+
attr_name = attribute_aliases[attr_name] || attr_name
|
169
|
+
attribute_types.key?(attr_name)
|
170
|
+
end
|
171
|
+
|
172
|
+
def _has_attribute?(attr_name) # :nodoc:
|
173
|
+
attribute_types.key?(attr_name)
|
155
174
|
end
|
156
175
|
end
|
157
176
|
|
158
177
|
# Returns +true+ if the given attribute is in the attributes hash, otherwise +false+.
|
159
178
|
#
|
160
179
|
# class Person < ActiveEntity::Base
|
180
|
+
# alias_attribute :new_name, :name
|
161
181
|
# end
|
162
182
|
#
|
163
183
|
# person = Person.new
|
164
|
-
# person.has_attribute?(:name)
|
165
|
-
# person.has_attribute?(
|
166
|
-
# person.has_attribute?(
|
184
|
+
# person.has_attribute?(:name) # => true
|
185
|
+
# person.has_attribute?(:new_name) # => true
|
186
|
+
# person.has_attribute?('age') # => true
|
187
|
+
# person.has_attribute?(:nothing) # => false
|
167
188
|
def has_attribute?(attr_name)
|
168
|
-
|
189
|
+
attr_name = attr_name.to_s
|
190
|
+
attr_name = self.class.attribute_aliases[attr_name] || attr_name
|
191
|
+
@attributes.key?(attr_name)
|
192
|
+
end
|
193
|
+
|
194
|
+
def _has_attribute?(attr_name) # :nodoc:
|
195
|
+
@attributes.key?(attr_name)
|
169
196
|
end
|
170
197
|
|
171
198
|
# Returns an array of names for the attributes available on this object.
|
@@ -209,6 +236,7 @@ module ActiveEntity
|
|
209
236
|
# person.attribute_for_inspect(:tag_ids)
|
210
237
|
# # => "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]"
|
211
238
|
def attribute_for_inspect(attr_name)
|
239
|
+
attr_name = attr_name.to_s
|
212
240
|
value = _read_attribute(attr_name)
|
213
241
|
format_for_inspect(value)
|
214
242
|
end
|
@@ -228,8 +256,9 @@ module ActiveEntity
|
|
228
256
|
# task.is_done = true
|
229
257
|
# task.attribute_present?(:title) # => true
|
230
258
|
# task.attribute_present?(:is_done) # => true
|
231
|
-
def attribute_present?(
|
232
|
-
|
259
|
+
def attribute_present?(attr_name)
|
260
|
+
attr_name = attr_name.to_s
|
261
|
+
value = _read_attribute(attr_name)
|
233
262
|
!value.nil? && !(value.respond_to?(:empty?) && value.empty?)
|
234
263
|
end
|
235
264
|
|
@@ -268,39 +297,6 @@ module ActiveEntity
|
|
268
297
|
write_attribute(attr_name, value)
|
269
298
|
end
|
270
299
|
|
271
|
-
# Returns the name of all database fields which have been read from this
|
272
|
-
# model. This can be useful in development mode to determine which fields
|
273
|
-
# need to be selected. For performance critical pages, selecting only the
|
274
|
-
# required fields can be an easy performance win (assuming you aren't using
|
275
|
-
# all of the fields on the model).
|
276
|
-
#
|
277
|
-
# For example:
|
278
|
-
#
|
279
|
-
# class PostsController < ActionController::Base
|
280
|
-
# after_action :print_accessed_fields, only: :index
|
281
|
-
#
|
282
|
-
# def index
|
283
|
-
# @posts = Post.all
|
284
|
-
# end
|
285
|
-
#
|
286
|
-
# private
|
287
|
-
#
|
288
|
-
# def print_accessed_fields
|
289
|
-
# p @posts.first.accessed_fields
|
290
|
-
# end
|
291
|
-
# end
|
292
|
-
#
|
293
|
-
# Which allows you to quickly change your code to:
|
294
|
-
#
|
295
|
-
# class PostsController < ActionController::Base
|
296
|
-
# def index
|
297
|
-
# @posts = Post.select(:id, :title, :author_id, :updated_at)
|
298
|
-
# end
|
299
|
-
# end
|
300
|
-
def accessed_fields
|
301
|
-
@attributes.accessed
|
302
|
-
end
|
303
|
-
|
304
300
|
private
|
305
301
|
|
306
302
|
def attribute_method?(attr_name)
|
@@ -308,12 +304,6 @@ module ActiveEntity
|
|
308
304
|
defined?(@attributes) && @attributes.key?(attr_name)
|
309
305
|
end
|
310
306
|
|
311
|
-
def attributes_with_values(attribute_names)
|
312
|
-
attribute_names.each_with_object({}) do |name, attrs|
|
313
|
-
attrs[name] = _read_attribute(name)
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
307
|
def format_for_inspect(value)
|
318
308
|
if value.is_a?(String) && value.length > 50
|
319
309
|
"#{value[0, 50]}...".inspect
|
@@ -46,7 +46,7 @@ module ActiveEntity
|
|
46
46
|
# task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
|
47
47
|
# task.read_attribute_before_type_cast(:completed_on) # => "2012-10-21"
|
48
48
|
def read_attribute_before_type_cast(attr_name)
|
49
|
-
|
49
|
+
attribute_before_type_cast(attr_name.to_s)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Returns a hash of attributes before typecasting and deserialization.
|
@@ -66,12 +66,12 @@ module ActiveEntity
|
|
66
66
|
private
|
67
67
|
|
68
68
|
# Dispatch target for <tt>*_before_type_cast</tt> attribute methods.
|
69
|
-
def attribute_before_type_cast(
|
70
|
-
|
69
|
+
def attribute_before_type_cast(attr_name)
|
70
|
+
@attributes[attr_name].value_before_type_cast
|
71
71
|
end
|
72
72
|
|
73
|
-
def attribute_came_from_user?(
|
74
|
-
@attributes[
|
73
|
+
def attribute_came_from_user?(attr_name)
|
74
|
+
@attributes[attr_name].came_from_user?
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -16,29 +16,27 @@ module ActiveEntity
|
|
16
16
|
|
17
17
|
# Returns the primary key column's value.
|
18
18
|
def id
|
19
|
-
primary_key
|
20
|
-
_read_attribute(primary_key) if primary_key
|
19
|
+
_read_attribute(@primary_key)
|
21
20
|
end
|
22
21
|
|
23
22
|
# Sets the primary key column's value.
|
24
23
|
def id=(value)
|
25
|
-
primary_key
|
26
|
-
_write_attribute(primary_key, value) if primary_key
|
24
|
+
_write_attribute(@primary_key, value)
|
27
25
|
end
|
28
26
|
|
29
27
|
# Queries the primary key column's value.
|
30
28
|
def id?
|
31
|
-
query_attribute(
|
29
|
+
query_attribute(@primary_key)
|
32
30
|
end
|
33
31
|
|
34
32
|
# Returns the primary key column's value before type cast.
|
35
33
|
def id_before_type_cast
|
36
|
-
read_attribute_before_type_cast(
|
34
|
+
read_attribute_before_type_cast(@primary_key)
|
37
35
|
end
|
38
36
|
|
39
37
|
# Returns the primary key column's previous value.
|
40
38
|
def id_was
|
41
|
-
attribute_was(
|
39
|
+
attribute_was(@primary_key)
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
@@ -48,7 +46,7 @@ module ActiveEntity
|
|
48
46
|
end
|
49
47
|
|
50
48
|
module ClassMethods
|
51
|
-
ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast id_was
|
49
|
+
ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast id_was).to_set
|
52
50
|
|
53
51
|
def instance_method_already_implemented?(method_name)
|
54
52
|
super || primary_key && ID_ATTRIBUTE_METHODS.include?(method_name)
|
@@ -31,12 +31,8 @@ module ActiveEntity
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
# Dispatch target for <tt>*?</tt> attribute methods.
|
37
|
-
def attribute?(attribute_name)
|
38
|
-
query_attribute(attribute_name)
|
39
|
-
end
|
34
|
+
alias :attribute? :query_attribute
|
35
|
+
private :attribute?
|
40
36
|
end
|
41
37
|
end
|
42
38
|
end
|
@@ -8,16 +8,14 @@ module ActiveEntity
|
|
8
8
|
module ClassMethods # :nodoc:
|
9
9
|
private
|
10
10
|
|
11
|
-
def define_method_attribute(name)
|
11
|
+
def define_method_attribute(name, owner:)
|
12
12
|
ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
|
13
|
-
|
13
|
+
owner, name
|
14
14
|
) do |temp_method_name, attr_name_expr|
|
15
|
-
|
16
|
-
def #{temp_method_name}
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
RUBY
|
15
|
+
owner <<
|
16
|
+
"def #{temp_method_name}" <<
|
17
|
+
" _read_attribute(#{attr_name_expr}) { |n| missing_attribute(n, caller) }" <<
|
18
|
+
"end"
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -29,13 +27,14 @@ module ActiveEntity
|
|
29
27
|
name = attr_name.to_s
|
30
28
|
name = self.class.attribute_aliases[name] || name
|
31
29
|
|
32
|
-
|
30
|
+
name = @primary_key if name == "id" && @primary_key
|
31
|
+
@attributes.fetch_value(name, &block)
|
33
32
|
end
|
34
33
|
|
35
34
|
# This method exists to avoid the expensive primary_key check internally, without
|
36
35
|
# breaking compatibility with the read_attribute API
|
37
36
|
def _read_attribute(attr_name, &block) # :nodoc
|
38
|
-
@attributes.fetch_value(attr_name
|
37
|
+
@attributes.fetch_value(attr_name, &block)
|
39
38
|
end
|
40
39
|
|
41
40
|
alias :attribute :_read_attribute
|
@@ -12,16 +12,14 @@ module ActiveEntity
|
|
12
12
|
module ClassMethods # :nodoc:
|
13
13
|
private
|
14
14
|
|
15
|
-
def define_method_attribute=(name)
|
15
|
+
def define_method_attribute=(name, owner:)
|
16
16
|
ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def #{temp_method_name}(value)
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
RUBY
|
17
|
+
owner, name, writer: true,
|
18
|
+
) do |temp_method_name, attr_name_expr|
|
19
|
+
owner <<
|
20
|
+
"def #{temp_method_name}(value)" <<
|
21
|
+
" _write_attribute(#{attr_name_expr}, value)" <<
|
22
|
+
"end"
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -33,28 +31,23 @@ module ActiveEntity
|
|
33
31
|
name = attr_name.to_s
|
34
32
|
name = self.class.attribute_aliases[name] || name
|
35
33
|
|
36
|
-
|
34
|
+
name = @primary_key if name == "id" && @primary_key
|
35
|
+
@attributes.write_from_user(name, value)
|
37
36
|
end
|
38
37
|
|
39
38
|
# This method exists to avoid the expensive primary_key check internally, without
|
40
39
|
# breaking compatibility with the write_attribute API
|
41
40
|
def _write_attribute(attr_name, value) # :nodoc:
|
42
|
-
|
43
|
-
|
44
|
-
@attributes.write_from_user(attr_name.to_s, value)
|
45
|
-
value
|
41
|
+
@attributes.write_from_user(attr_name, value)
|
46
42
|
end
|
47
43
|
|
44
|
+
alias :attribute= :_write_attribute
|
45
|
+
private :attribute=
|
46
|
+
|
48
47
|
private
|
49
48
|
|
50
49
|
def write_attribute_without_type_cast(attr_name, value)
|
51
|
-
@attributes.write_cast_value(attr_name
|
52
|
-
value
|
53
|
-
end
|
54
|
-
|
55
|
-
# Dispatch target for <tt>*=</tt> attribute methods.
|
56
|
-
def attribute=(attribute_name, value)
|
57
|
-
_write_attribute(attribute_name, value)
|
50
|
+
@attributes.write_cast_value(attr_name, value)
|
58
51
|
end
|
59
52
|
end
|
60
53
|
end
|
data/lib/active_entity/base.rb
CHANGED
@@ -6,7 +6,6 @@ require "active_support/descendants_tracker"
|
|
6
6
|
require "active_support/time"
|
7
7
|
require "active_support/core_ext/class/subclasses"
|
8
8
|
require "active_entity/attribute_decorators"
|
9
|
-
require "active_entity/define_callbacks"
|
10
9
|
require "active_entity/attributes"
|
11
10
|
|
12
11
|
module ActiveEntity #:nodoc:
|
@@ -280,7 +279,6 @@ module ActiveEntity #:nodoc:
|
|
280
279
|
include Validations
|
281
280
|
include Attributes
|
282
281
|
include AttributeDecorators
|
283
|
-
include DefineCallbacks
|
284
282
|
include AttributeMethods
|
285
283
|
include Callbacks
|
286
284
|
include Associations
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveEntity
|
4
|
-
|
5
|
-
# define callbacks, but continue to have its version of +save+ be the super
|
6
|
-
# method of ActiveEntity::Callbacks. This will be removed when the removal
|
7
|
-
# of deprecated code removes this need.
|
8
|
-
module DefineCallbacks
|
4
|
+
module Callbacks
|
9
5
|
extend ActiveSupport::Concern
|
10
6
|
|
7
|
+
CALLBACKS = [
|
8
|
+
:after_initialize, :before_validation, :after_validation
|
9
|
+
]
|
10
|
+
|
11
11
|
module ClassMethods # :nodoc:
|
12
12
|
include ActiveModel::Callbacks
|
13
13
|
end
|
data/lib/active_entity/core.rb
CHANGED
@@ -27,7 +27,7 @@ module ActiveEntity
|
|
27
27
|
raise ArgumentError, "Must provide one of option :class_name or :class."
|
28
28
|
end
|
29
29
|
unless @klass < ActiveRecord::Base
|
30
|
-
raise ArgumentError, "Class must be an Active Entity model, but got #{@
|
30
|
+
raise ArgumentError, "Class must be an Active Entity model, but got #{@klass}."
|
31
31
|
end
|
32
32
|
if @klass.abstract_class?
|
33
33
|
raise ArgumentError, "Class can't be an abstract class."
|
@@ -39,13 +39,6 @@ module ActiveEntity
|
|
39
39
|
value = map_enum_attribute(finder_class, attribute, value)
|
40
40
|
|
41
41
|
relation = build_relation(finder_class, attribute, value)
|
42
|
-
if record.persisted?
|
43
|
-
if finder_class.primary_key
|
44
|
-
relation = relation.where.not(finder_class.primary_key => record.id_in_database)
|
45
|
-
else
|
46
|
-
raise UnknownPrimaryKey.new(finder_class, "Cannot validate uniqueness for persisted record without primary key.")
|
47
|
-
end
|
48
|
-
end
|
49
42
|
relation = scope_relation(record, relation)
|
50
43
|
relation = relation.merge(options[:conditions]) if options[:conditions]
|
51
44
|
|
@@ -94,11 +87,7 @@ module ActiveEntity
|
|
94
87
|
|
95
88
|
def scope_relation(record, relation)
|
96
89
|
Array(options[:scope]).each do |scope_item|
|
97
|
-
scope_value =
|
98
|
-
record.association(scope_item).reader
|
99
|
-
else
|
100
|
-
record._read_attribute(scope_item)
|
101
|
-
end
|
90
|
+
scope_value = record._read_attribute(scope_item)
|
102
91
|
relation = relation.where(scope_item => scope_value)
|
103
92
|
end
|
104
93
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeentity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasl
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -89,10 +89,10 @@ files:
|
|
89
89
|
- lib/active_entity/attribute_methods/write.rb
|
90
90
|
- lib/active_entity/attributes.rb
|
91
91
|
- lib/active_entity/base.rb
|
92
|
+
- lib/active_entity/callbacks.rb
|
92
93
|
- lib/active_entity/coders/json.rb
|
93
94
|
- lib/active_entity/coders/yaml_column.rb
|
94
95
|
- lib/active_entity/core.rb
|
95
|
-
- lib/active_entity/define_callbacks.rb
|
96
96
|
- lib/active_entity/enum.rb
|
97
97
|
- lib/active_entity/errors.rb
|
98
98
|
- lib/active_entity/gem_version.rb
|
@@ -135,7 +135,7 @@ homepage: https://github.com/jasl/activeentity
|
|
135
135
|
licenses:
|
136
136
|
- MIT
|
137
137
|
metadata: {}
|
138
|
-
post_install_message:
|
138
|
+
post_install_message:
|
139
139
|
rdoc_options: []
|
140
140
|
require_paths:
|
141
141
|
- lib
|
@@ -146,12 +146,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: 2.5.0
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- - "
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
151
|
+
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.1.
|
154
|
-
signing_key:
|
153
|
+
rubygems_version: 3.1.4
|
154
|
+
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Rails virtual model solution based on ActiveModel.
|
157
157
|
test_files: []
|