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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be73fbca7fffeee0f67d261c388d9389c98220d6db6748a3ba349e67d210567c
4
- data.tar.gz: af657447cb5eddd2722cd3b30940e721d91d4357c64ed6e78485cf9934567705
3
+ metadata.gz: 2fb8165e3bfb7ae465f431ff850dd0532cb2fc6aca0e9fa740b9c4e565fb9435
4
+ data.tar.gz: 58e8c95928e288579b146a8fb4c211762c592ff5bcbcd724b8c366c7429d922d
5
5
  SHA512:
6
- metadata.gz: 3a9a10892d969e0a6eb51dc5a34e57bb056f3ec16a1499fa16545b1bcfd5cebb9d4f140d66921d85107e1c7d83742c5890fd9d4373ad2a094d71cb235e309171
7
- data.tar.gz: 06ec78753cf3bfff0e476b8b276f2f4d6e933a8fa4a6b0c62161a2a4e26470eb838f4528b44fccd7ecdb8c03917385d34b7c777171bc767ec142cc2c3613025f
6
+ metadata.gz: 046b7568fc5cfa44f594dfbbbcbccbc3c440cb2d823d1553a685ddb2594f27131c67fd51822570fc479138150cdb6833efce86ef22bb9ef91c4891a8002365e4
7
+ data.tar.gz: bf00cb2ec0b879d7c4fbdad793f012d460f4da31aa134ea7f6c656054269e85f797e5c7931156d3dfa9bd39c8eb1850ba50bd75e83cbbe749fffa93442066f38
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
- ## [0.0.5] - 2025-01-21
1
+ ## [0.0.7] - 2025-01-22
2
2
 
3
3
  - Make use of ModelAttributeHelpers
4
+ - Handle boolean column type
5
+ - Fix ActiveRecordThunk#== bug
4
6
 
5
7
  ## [0.0.3] - 2025-01-17
6
8
 
@@ -19,7 +19,8 @@ module Foobara
19
19
 
20
20
  BuiltinTypes.install_type_declaration_extensions_for(ExtendActiveRecordTypeDeclaration)
21
21
 
22
- ActiveRecord::Base.include Foobara::ModelAttributeHelpers::Concerns::AttributeHelpers
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 ActiveRecordFoobaraMethods
2
- extend ActiveSupport::Concern
1
+ module Foobara
2
+ module ActiveRecordType
3
+ module ActiveRecordFoobaraMethods
4
+ extend ActiveSupport::Concern
3
5
 
4
- class_methods do
5
- attr_accessor :foobara_type, :foobara_attributes_type
6
+ class_methods do
7
+ attr_accessor :foobara_type, :foobara_attributes_type
6
8
 
7
- # TODO: implement this or figure out how to re-use the methods from Entity/Model
8
- def foobara_associations
9
- {}
10
- end
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
- def foobara_primary_key_attribute
13
- primary_key
14
- end
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
- def foobara_primary_key_type
17
- return @foobara_primary_key_type if @foobara_primary_key_type
26
+ def foobara_attributes_for_create(...)
27
+ TypeDeclarations::Attributes.reject(super, :created_at, :updated_at)
28
+ end
18
29
 
19
- domain = foobara_type.foobara_domain
20
- declaration = Foobara::ActiveRecordType.column_name_to_foobara_type_declaration(self, primary_key)
21
- @foobara_primary_key_type = domain.foobara_type_from_declaration(declaration)
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
@@ -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
@@ -10,7 +10,7 @@ module Foobara
10
10
  column_type = column.sql_type_metadata.type
11
11
 
12
12
  type_declaration = case column_type
13
- when :integer, :string, :datetime
13
+ when :integer, :string, :datetime, :boolean
14
14
  column_type
15
15
  else
16
16
  # :nocov:
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.5
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-22 00:00:00.000000000 Z
10
+ date: 2025-01-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord