foobara-active-record-type 0.0.5 → 0.0.7
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/CHANGELOG.md +3 -1
- data/lib/foobara/active_record_type.rb +2 -1
- data/src/active_record_foobara_methods.rb +40 -18
- data/src/active_record_thunk.rb +6 -0
- data/src/active_record_type.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb8165e3bfb7ae465f431ff850dd0532cb2fc6aca0e9fa740b9c4e565fb9435
|
4
|
+
data.tar.gz: 58e8c95928e288579b146a8fb4c211762c592ff5bcbcd724b8c366c7429d922d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046b7568fc5cfa44f594dfbbbcbccbc3c440cb2d823d1553a685ddb2594f27131c67fd51822570fc479138150cdb6833efce86ef22bb9ef91c4891a8002365e4
|
7
|
+
data.tar.gz: bf00cb2ec0b879d7c4fbdad793f012d460f4da31aa134ea7f6c656054269e85f797e5c7931156d3dfa9bd39c8eb1850ba50bd75e83cbbe749fffa93442066f38
|
data/CHANGELOG.md
CHANGED
@@ -19,7 +19,8 @@ module Foobara
|
|
19
19
|
|
20
20
|
BuiltinTypes.install_type_declaration_extensions_for(ExtendActiveRecordTypeDeclaration)
|
21
21
|
|
22
|
-
ActiveRecord::Base.include
|
22
|
+
ActiveRecord::Base.include ModelAttributeHelpers::Concerns::AttributeHelpers
|
23
|
+
ActiveRecord::Base.include ActiveRecordFoobaraMethods
|
23
24
|
end
|
24
25
|
|
25
26
|
def reset_all
|
@@ -1,26 +1,48 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module Foobara
|
2
|
+
module ActiveRecordType
|
3
|
+
module ActiveRecordFoobaraMethods
|
4
|
+
extend ActiveSupport::Concern
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
class_methods do
|
7
|
+
attr_accessor :foobara_type, :foobara_attributes_type
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
# TODO: implement this or figure out how to re-use the methods from Entity/Model
|
10
|
+
def foobara_associations
|
11
|
+
{}
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def foobara_primary_key_attribute
|
15
|
+
primary_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def foobara_primary_key_type
|
19
|
+
return @foobara_primary_key_type if @foobara_primary_key_type
|
20
|
+
|
21
|
+
domain = foobara_type.foobara_domain
|
22
|
+
declaration = Foobara::ActiveRecordType.column_name_to_foobara_type_declaration(self, primary_key)
|
23
|
+
@foobara_primary_key_type = domain.foobara_type_from_declaration(declaration)
|
24
|
+
end
|
15
25
|
|
16
|
-
|
17
|
-
|
26
|
+
def foobara_attributes_for_create(...)
|
27
|
+
TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
|
28
|
+
end
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
def foobara_attributes_for_update(...)
|
31
|
+
TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
|
32
|
+
end
|
33
|
+
|
34
|
+
def foobara_attributes_for_aggregate_update(...)
|
35
|
+
TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
|
36
|
+
end
|
37
|
+
|
38
|
+
def foobara_attributes_for_atom_update(...)
|
39
|
+
TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
|
40
|
+
end
|
41
|
+
|
42
|
+
def foobara_attributes_for_find_by(...)
|
43
|
+
TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
|
44
|
+
end
|
45
|
+
end
|
22
46
|
end
|
23
47
|
end
|
24
48
|
end
|
25
|
-
|
26
|
-
ActiveRecord::Base.include ActiveRecordFoobaraMethods
|
data/src/active_record_thunk.rb
CHANGED
@@ -51,6 +51,12 @@ module Foobara
|
|
51
51
|
end
|
52
52
|
# rubocop:enable Style/TrivialAccessors
|
53
53
|
|
54
|
+
def ==(other)
|
55
|
+
return false unless @foobara_primary_key
|
56
|
+
|
57
|
+
other.instance_of?(@foobara_active_record_class) && @foobara_primary_key == other.id
|
58
|
+
end
|
59
|
+
|
54
60
|
private
|
55
61
|
|
56
62
|
# TODO: there are probably several other methods that don't require loading
|
data/src/active_record_type.rb
CHANGED
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.7
|
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-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activerecord
|