foobara-active-record-type 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/foobara/active_record_type.rb +8 -0
- data/src/serializers/active_record_aggregate_serializer.rb +15 -0
- data/src/serializers/active_record_atomic_serializer.rb +19 -0
- data/src/serializers/active_record_entities_to_primary_keys_serializer.rb +18 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 173e73fbfbc613a24ac317aacedbed070c7a311f79ce96f1afce275aa839f854
|
4
|
+
data.tar.gz: 84a8e463d431d639c16c80b983e4a10d663775f68b005d32fb2c71ad526e6d48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44346b0a6091909ec26e95df4cfd9d0d5987f0e34af5bbc0bcc9bc228384b7bb26ad1e56e3cfa55d985185f4adc30c7f892991610913eac9024033c1cd3ea769
|
7
|
+
data.tar.gz: f9769cac666e008a142e03f3a464dfd975962f6ba99eca98a412c35e0c12eb271043fc3cdbe28ce0aae8cf68d0c74219fb2f1fd46e7bb15481262685de7d4c84
|
data/CHANGELOG.md
CHANGED
@@ -21,6 +21,14 @@ module Foobara
|
|
21
21
|
|
22
22
|
ActiveRecord::Base.include ModelAttributeHelpers::Concerns::AttributeHelpers
|
23
23
|
ActiveRecord::Base.include ActiveRecordFoobaraMethods
|
24
|
+
|
25
|
+
if defined?(Foobara::CommandConnectors::RailsCommandConnector)
|
26
|
+
Foobara::CommandConnectors::RailsCommandConnector.default_serializers = [
|
27
|
+
Foobara::CommandConnectors::Serializers::ErrorsSerializer,
|
28
|
+
Foobara::CommandConnectors::Serializers::ActiveRecordAtomicSerializer,
|
29
|
+
Foobara::CommandConnectors::Serializers::JsonSerializer
|
30
|
+
]
|
31
|
+
end
|
24
32
|
end
|
25
33
|
|
26
34
|
def reset_all
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Foobara
|
2
|
+
module CommandConnectors
|
3
|
+
module Serializers
|
4
|
+
class ActiveRecordAggregateSerializer < AggregateSerializer
|
5
|
+
def serialize(object)
|
6
|
+
if object.is_a?(ActiveRecord::Base)
|
7
|
+
super(object.attributes)
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Foobara
|
2
|
+
module CommandConnectors
|
3
|
+
module Serializers
|
4
|
+
class ActiveRecordAtomicSerializer < AtomicSerializer
|
5
|
+
def serialize(object)
|
6
|
+
if object.is_a?(ActiveRecord::Base)
|
7
|
+
super(object.attributes)
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def entities_to_primary_keys_serializer
|
14
|
+
@entities_to_primary_keys_serializer ||= ActiveRecordEntitiesToPrimaryKeysSerializer.new(declaration_data)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "foobara/command_connectors"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module CommandConnectors
|
5
|
+
module Serializers
|
6
|
+
class ActiveRecordEntitiesToPrimaryKeysSerializer < EntitiesToPrimaryKeysSerializer
|
7
|
+
def serialize(object)
|
8
|
+
if object.is_a?(ActiveRecord::Base)
|
9
|
+
attribute = object.class.primary_key
|
10
|
+
object.send(attribute)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-active-record-type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-25 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activerecord
|
@@ -65,6 +65,9 @@ files:
|
|
65
65
|
- src/extend_active_record_type_declaration/validate_primary_key_is_symbol.rb
|
66
66
|
- src/extend_active_record_type_declaration/validate_primary_key_present.rb
|
67
67
|
- src/extend_active_record_type_declaration/validate_primary_key_references_attribute.rb
|
68
|
+
- src/serializers/active_record_aggregate_serializer.rb
|
69
|
+
- src/serializers/active_record_atomic_serializer.rb
|
70
|
+
- src/serializers/active_record_entities_to_primary_keys_serializer.rb
|
68
71
|
homepage: https://github.com/foobara/active-record-type
|
69
72
|
licenses:
|
70
73
|
- MPL-2.0
|