activeentity 0.0.1.beta14 → 0.0.1.beta15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -4
  4. data/Rakefile +7 -7
  5. data/lib/active_entity.rb +29 -7
  6. data/lib/active_entity/aggregations.rb +2 -1
  7. data/lib/active_entity/associations.rb +46 -24
  8. data/lib/active_entity/associations/{embedded → embeds}/association.rb +2 -2
  9. data/lib/active_entity/associations/{embedded → embeds}/builder/association.rb +1 -1
  10. data/lib/active_entity/associations/{embedded → embeds}/builder/collection_association.rb +1 -1
  11. data/lib/active_entity/associations/{embedded → embeds}/builder/embedded_in.rb +1 -1
  12. data/lib/active_entity/associations/{embedded → embeds}/builder/embeds_many.rb +1 -1
  13. data/lib/active_entity/associations/{embedded → embeds}/builder/embeds_one.rb +1 -1
  14. data/lib/active_entity/associations/{embedded → embeds}/builder/singular_association.rb +1 -1
  15. data/lib/active_entity/associations/{embedded → embeds}/collection_association.rb +1 -1
  16. data/lib/active_entity/associations/{embedded → embeds}/collection_proxy.rb +2 -2
  17. data/lib/active_entity/associations/{embedded → embeds}/embedded_in_association.rb +1 -1
  18. data/lib/active_entity/associations/{embedded → embeds}/embeds_many_association.rb +1 -1
  19. data/lib/active_entity/associations/{embedded → embeds}/embeds_one_association.rb +2 -1
  20. data/lib/active_entity/associations/{embedded → embeds}/singular_association.rb +1 -1
  21. data/lib/active_entity/attribute_assignment.rb +9 -3
  22. data/lib/active_entity/attribute_methods.rb +12 -11
  23. data/lib/active_entity/attribute_methods/before_type_cast.rb +1 -1
  24. data/lib/active_entity/attribute_methods/dirty.rb +13 -0
  25. data/lib/active_entity/attribute_methods/primary_key.rb +1 -1
  26. data/lib/active_entity/attribute_methods/query.rb +11 -4
  27. data/lib/active_entity/attribute_methods/read.rb +1 -3
  28. data/lib/active_entity/attribute_methods/time_zone_conversion.rb +2 -0
  29. data/lib/active_entity/attribute_methods/write.rb +4 -6
  30. data/lib/active_entity/attributes.rb +76 -2
  31. data/lib/active_entity/base.rb +3 -12
  32. data/lib/active_entity/core.rb +97 -39
  33. data/lib/active_entity/define_callbacks.rb +4 -0
  34. data/lib/active_entity/enum.rb +30 -4
  35. data/lib/active_entity/errors.rb +0 -11
  36. data/lib/active_entity/gem_version.rb +1 -1
  37. data/lib/active_entity/inheritance.rb +4 -106
  38. data/lib/active_entity/integration.rb +1 -1
  39. data/lib/active_entity/model_schema.rb +0 -12
  40. data/lib/active_entity/nested_attributes.rb +5 -12
  41. data/lib/active_entity/railtie.rb +61 -1
  42. data/lib/active_entity/readonly_attributes.rb +9 -1
  43. data/lib/active_entity/reflection.rb +22 -19
  44. data/lib/active_entity/serialization.rb +9 -6
  45. data/lib/active_entity/store.rb +51 -2
  46. data/lib/active_entity/type.rb +8 -8
  47. data/lib/active_entity/type/registry.rb +5 -5
  48. data/lib/active_entity/{validate_embedded_association.rb → validate_embeds_association.rb} +6 -6
  49. data/lib/active_entity/validations.rb +2 -6
  50. data/lib/active_entity/validations/associated.rb +1 -1
  51. data/lib/active_entity/validations/{uniqueness_in_embedding.rb → uniqueness_in_embeds.rb} +1 -1
  52. data/lib/active_entity/validations/uniqueness_on_active_record.rb +46 -40
  53. metadata +27 -30
  54. data/lib/active_entity/type/decimal_without_scale.rb +0 -15
  55. data/lib/active_entity/type/hash_lookup_type_map.rb +0 -25
  56. data/lib/active_entity/type/type_map.rb +0 -62
  57. data/lib/tasks/active_entity_tasks.rake +0 -6
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeentity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta14
4
+ version: 0.0.1.beta15
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0.rc1
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '7.0'
@@ -24,9 +24,9 @@ dependencies:
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 6.0.0.rc1
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7.0'
@@ -34,9 +34,9 @@ dependencies:
34
34
  name: activemodel
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 6.0.0.rc1
39
+ version: '6.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '7.0'
@@ -44,9 +44,9 @@ dependencies:
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 6.0.0.rc1
49
+ version: '6.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '7.0'
@@ -63,23 +63,24 @@ files:
63
63
  - lib/active_entity.rb
64
64
  - lib/active_entity/aggregations.rb
65
65
  - lib/active_entity/associations.rb
66
- - lib/active_entity/associations/embedded/association.rb
67
- - lib/active_entity/associations/embedded/builder/association.rb
68
- - lib/active_entity/associations/embedded/builder/collection_association.rb
69
- - lib/active_entity/associations/embedded/builder/embedded_in.rb
70
- - lib/active_entity/associations/embedded/builder/embeds_many.rb
71
- - lib/active_entity/associations/embedded/builder/embeds_one.rb
72
- - lib/active_entity/associations/embedded/builder/singular_association.rb
73
- - lib/active_entity/associations/embedded/collection_association.rb
74
- - lib/active_entity/associations/embedded/collection_proxy.rb
75
- - lib/active_entity/associations/embedded/embedded_in_association.rb
76
- - lib/active_entity/associations/embedded/embeds_many_association.rb
77
- - lib/active_entity/associations/embedded/embeds_one_association.rb
78
- - lib/active_entity/associations/embedded/singular_association.rb
66
+ - lib/active_entity/associations/embeds/association.rb
67
+ - lib/active_entity/associations/embeds/builder/association.rb
68
+ - lib/active_entity/associations/embeds/builder/collection_association.rb
69
+ - lib/active_entity/associations/embeds/builder/embedded_in.rb
70
+ - lib/active_entity/associations/embeds/builder/embeds_many.rb
71
+ - lib/active_entity/associations/embeds/builder/embeds_one.rb
72
+ - lib/active_entity/associations/embeds/builder/singular_association.rb
73
+ - lib/active_entity/associations/embeds/collection_association.rb
74
+ - lib/active_entity/associations/embeds/collection_proxy.rb
75
+ - lib/active_entity/associations/embeds/embedded_in_association.rb
76
+ - lib/active_entity/associations/embeds/embeds_many_association.rb
77
+ - lib/active_entity/associations/embeds/embeds_one_association.rb
78
+ - lib/active_entity/associations/embeds/singular_association.rb
79
79
  - lib/active_entity/attribute_assignment.rb
80
80
  - lib/active_entity/attribute_decorators.rb
81
81
  - lib/active_entity/attribute_methods.rb
82
82
  - lib/active_entity/attribute_methods/before_type_cast.rb
83
+ - lib/active_entity/attribute_methods/dirty.rb
83
84
  - lib/active_entity/attribute_methods/primary_key.rb
84
85
  - lib/active_entity/attribute_methods/query.rb
85
86
  - lib/active_entity/attribute_methods/read.rb
@@ -110,8 +111,6 @@ files:
110
111
  - lib/active_entity/type.rb
111
112
  - lib/active_entity/type/date.rb
112
113
  - lib/active_entity/type/date_time.rb
113
- - lib/active_entity/type/decimal_without_scale.rb
114
- - lib/active_entity/type/hash_lookup_type_map.rb
115
114
  - lib/active_entity/type/internal/timezone.rb
116
115
  - lib/active_entity/type/json.rb
117
116
  - lib/active_entity/type/modifiers/array.rb
@@ -120,20 +119,18 @@ files:
120
119
  - lib/active_entity/type/serialized.rb
121
120
  - lib/active_entity/type/text.rb
122
121
  - lib/active_entity/type/time.rb
123
- - lib/active_entity/type/type_map.rb
124
122
  - lib/active_entity/type/unsigned_integer.rb
125
- - lib/active_entity/validate_embedded_association.rb
123
+ - lib/active_entity/validate_embeds_association.rb
126
124
  - lib/active_entity/validations.rb
127
125
  - lib/active_entity/validations/absence.rb
128
126
  - lib/active_entity/validations/associated.rb
129
127
  - lib/active_entity/validations/length.rb
130
128
  - lib/active_entity/validations/presence.rb
131
129
  - lib/active_entity/validations/subset.rb
132
- - lib/active_entity/validations/uniqueness_in_embedding.rb
130
+ - lib/active_entity/validations/uniqueness_in_embeds.rb
133
131
  - lib/active_entity/validations/uniqueness_on_active_record.rb
134
132
  - lib/active_entity/version.rb
135
133
  - lib/core_ext/array_without_blank.rb
136
- - lib/tasks/active_entity_tasks.rake
137
134
  homepage: https://github.com/jasl/activeentity
138
135
  licenses:
139
136
  - MIT
@@ -153,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
150
  - !ruby/object:Gem::Version
154
151
  version: 1.3.1
155
152
  requirements: []
156
- rubygems_version: 3.0.4
153
+ rubygems_version: 3.1.2
157
154
  signing_key:
158
155
  specification_version: 4
159
156
  summary: Rails virtual model solution based on ActiveModel.
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveEntity
4
- module Type
5
- class DecimalWithoutScale < ActiveModel::Type::BigInteger # :nodoc:
6
- def type
7
- :decimal
8
- end
9
-
10
- def type_cast_for_schema(value)
11
- value.to_s.inspect
12
- end
13
- end
14
- end
15
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveEntity
4
- module Type
5
- class HashLookupTypeMap < TypeMap # :nodoc:
6
- def alias_type(type, alias_type)
7
- register_type(type) { |_, *args| lookup(alias_type, *args) }
8
- end
9
-
10
- def key?(key)
11
- @mapping.key?(key)
12
- end
13
-
14
- def keys
15
- @mapping.keys
16
- end
17
-
18
- private
19
-
20
- def perform_fetch(type, *args, &block)
21
- @mapping.fetch(type, block).call(type, *args)
22
- end
23
- end
24
- end
25
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "concurrent/map"
4
-
5
- module ActiveEntity
6
- module Type
7
- class TypeMap # :nodoc:
8
- def initialize
9
- @mapping = {}
10
- @cache = Concurrent::Map.new do |h, key|
11
- h.fetch_or_store(key, Concurrent::Map.new)
12
- end
13
- end
14
-
15
- def lookup(lookup_key, *args)
16
- fetch(lookup_key, *args) { Type.default_value }
17
- end
18
-
19
- def fetch(lookup_key, *args, &block)
20
- @cache[lookup_key].fetch_or_store(args) do
21
- perform_fetch(lookup_key, *args, &block)
22
- end
23
- end
24
-
25
- def register_type(key, value = nil, &block)
26
- raise ::ArgumentError unless value || block
27
- @cache.clear
28
-
29
- if block
30
- @mapping[key] = block
31
- else
32
- @mapping[key] = proc { value }
33
- end
34
- end
35
-
36
- def alias_type(key, target_key)
37
- register_type(key) do |sql_type, *args|
38
- metadata = sql_type[/\(.*\)/, 0]
39
- lookup("#{target_key}#{metadata}", *args)
40
- end
41
- end
42
-
43
- def clear
44
- @mapping.clear
45
- end
46
-
47
- private
48
-
49
- def perform_fetch(lookup_key, *args)
50
- matching_pair = @mapping.reverse_each.detect do |key, _|
51
- key === lookup_key
52
- end
53
-
54
- if matching_pair
55
- matching_pair.last.call(lookup_key, *args)
56
- else
57
- yield lookup_key, *args
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # desc "Explaining what the task does"
4
- # task :active_entity do
5
- # # Task goes here
6
- # end