foobara-active-record-type 0.0.2 → 0.0.4

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: 308b78e110004588dedfaec131948d47f060ed15fa8a09fa241af01d15bf83d7
4
- data.tar.gz: a17c4130c51c4d2cc6c51a48ee50b5b176bd98fd0237fe8cf26c225a9a2a971e
3
+ metadata.gz: 1328ea690e597739be16596f51e9b71c289486409d87f6e005e4a84c47fc413b
4
+ data.tar.gz: f02618973852ed64a501b8ec4cde0872932c21a53aa3ae6678b27e71be4476b2
5
5
  SHA512:
6
- metadata.gz: d8fa16c2ba0deaf38e9d0f66d273b939be62d69bb8eb85590574d0eec1d472a966513154774d8fbaff8744767ceb45a398ec1faeb6c2ed2b497e6d8a4bdf0443
7
- data.tar.gz: 9e47b6836d783f38b90636d3713da58222a8c3668ebac313736b63cd08b40b25c304d73ffc4b8248608ac6215860083fb967244f7b5364b57f730945df841360
6
+ metadata.gz: 9f2901fa9461fcecd6adbf4bd8506e952d657d946d5e8b6a012a8df1e7ea9460b72416fd4e321e1e8108c21e383ed1c1d808077eebbc38d431a968bdd7ac17a3
7
+ data.tar.gz: 9d6b34ce44b69da4e20cb8245eb09886b7d5af88ecef493b236c081c7948250822b3e740ab09a790934d9ec86825bb6f65e5be58684264adbbf3fa3851c1c7e2
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
- ## [0.0.2]
1
+ ## [0.0.4] - 2025-01-21
2
+
3
+ - Make use of ModelAttributeHelpers
4
+
5
+ ## [0.0.3] - 2025-01-17
2
6
 
3
7
  - Fix problem where the first time a type is declared via an
4
8
  active record class it has a complex declaration hash instead of a simple
5
9
  registered class lookup
6
10
 
7
- ## [0.0.1]
11
+ ## [0.0.1] - 2025-01-03
8
12
 
9
13
  - Release as a gem
10
14
 
@@ -18,6 +18,8 @@ module Foobara
18
18
  )
19
19
 
20
20
  BuiltinTypes.install_type_declaration_extensions_for(ExtendActiveRecordTypeDeclaration)
21
+
22
+ ActiveRecord::Base.include Foobara::ModelAttributeHelpers::Concerns::AttributeHelpers
21
23
  end
22
24
 
23
25
  def reset_all
@@ -2,7 +2,12 @@ module ActiveRecordFoobaraMethods
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  class_methods do
5
- attr_accessor :foobara_type
5
+ attr_accessor :foobara_type, :foobara_attributes_type
6
+
7
+ # TODO: implement this or figure out how to re-use the methods from Entity/Model
8
+ def foobara_associations
9
+ {}
10
+ end
6
11
  end
7
12
  end
8
13
 
@@ -10,8 +10,10 @@ module Foobara
10
10
  active_record_superclass = active_record_class.superclass
11
11
 
12
12
  if active_record_superclass != ActiveRecord::Base
13
- # this will register a foobara type for the base class
14
- type_for_declaration(active_record_class.superclass)
13
+ if active_record_superclass.attribute_names.include?(active_record_class.primary_key)
14
+ # this will register a foobara type for the base class
15
+ type_for_declaration(active_record_class.superclass)
16
+ end
15
17
  end
16
18
 
17
19
  {
@@ -13,7 +13,9 @@ module Foobara
13
13
  handler = handler_for_class(TypeDeclarations::Handlers::ExtendAttributesTypeDeclaration)
14
14
  attributes_type_declaration = type.declaration_data[:attributes_declaration]
15
15
 
16
- type.element_types = handler.process_value!(attributes_type_declaration).element_types
16
+ active_record_class.foobara_attributes_type = handler.process_value!(attributes_type_declaration)
17
+
18
+ type.element_types = active_record_class.foobara_attributes_type.element_types
17
19
  type_name = type.declaration_data[:name]
18
20
 
19
21
  # We don't want to check that the active record is valid as if it were a model
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.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-17 00:00:00.000000000 Z
10
+ date: 2025-01-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord