dynamic-active-model 0.7.1 → 0.8.0

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: df7b50db8f5ebf370a804113e91fd1b7c74dc56e2616eb3e82f4306e090947fd
4
- data.tar.gz: ef184fe05e6418126ad365c49a9eb909c6ae203f1f4659293f317b5dda1b8903
3
+ metadata.gz: df4da0b0a5a5026754e0624dd508604ac4796ac3f60f37fa82018691fa596f3f
4
+ data.tar.gz: d42ea5435c3ad98e7bb6e9c4489df62db14b7b6199df3e0247989ad7b8a6a725
5
5
  SHA512:
6
- metadata.gz: f83649207e490df3cd43969cd435fb92c59d50db18338c024f09e1e42dec44ee58bf066d2d0164358311a351445ba382b1991e61ebed72dd1b53a2a7ee803ebf
7
- data.tar.gz: 13703007a12312bd93d5c175d9ab23c5c1c56c6f4f37929d45280490a8e8438cbb68fb653984372149c9ef527a996b8f8dcb001ee3700f7fb95a9accaf91bf74
6
+ metadata.gz: 986938faee17bc087e8260f468bf6c346244e291527c0f827b0ce0e227d079b22c082848eadb202a93d51798124787e496f343c9c4221eec0db652b3d3cb8218
7
+ data.tar.gz: f0d2af7a8da7d120dc82b3600ed8b3daef0a5d0eb7c581a2fc60dbc205b0440cb27cf01d792ffb0aeaa481756db5d63e603e2548ea3e5153b007c6ebffdce4b8
@@ -150,7 +150,11 @@ module DynamicActiveModel
150
150
  # @return [Class] The updated model class
151
151
  def update_model(table_name, file = nil, &block)
152
152
  model = get_model!(table_name)
153
- ModelUpdater.new(model).instance_eval(File.read(file), file, 1) if file
153
+ if file
154
+ updater = ModelUpdater.new(model)
155
+ ctx = updater.instance_eval { binding }
156
+ eval(File.read(file), ctx, file, 1) # rubocop:disable Security/Eval -- extension files are trusted code
157
+ end
154
158
  model.class_eval(&block) if block
155
159
  model
156
160
  end
@@ -62,33 +62,25 @@ module DynamicActiveModel
62
62
  # Gets all has_many relationships for the model
63
63
  # @return [Array<ActiveRecord::Reflection::HasManyReflection>]
64
64
  def all_has_many_relationships
65
- @model.reflect_on_all_associations.select do |assoc|
66
- assoc.is_a?(ActiveRecord::Reflection::HasManyReflection)
67
- end
65
+ @model.reflect_on_all_associations.grep(ActiveRecord::Reflection::HasManyReflection)
68
66
  end
69
67
 
70
68
  # Gets all belongs_to relationships for the model
71
69
  # @return [Array<ActiveRecord::Reflection::BelongsToReflection>]
72
70
  def all_belongs_to_relationships
73
- @model.reflect_on_all_associations.select do |assoc|
74
- assoc.is_a?(ActiveRecord::Reflection::BelongsToReflection)
75
- end
71
+ @model.reflect_on_all_associations.grep(ActiveRecord::Reflection::BelongsToReflection)
76
72
  end
77
73
 
78
74
  # Gets all has_one relationships for the model
79
75
  # @return [Array<ActiveRecord::Reflection::HasOneReflection>]
80
76
  def all_has_one_relationships
81
- @model.reflect_on_all_associations.select do |assoc|
82
- assoc.is_a?(ActiveRecord::Reflection::HasOneReflection)
83
- end
77
+ @model.reflect_on_all_associations.grep(ActiveRecord::Reflection::HasOneReflection)
84
78
  end
85
79
 
86
80
  # Gets all has_and_belongs_to_many relationships for the model
87
81
  # @return [Array<ActiveRecord::Reflection::HasAndBelongsToManyReflection>]
88
82
  def all_has_and_belongs_to_many_relationships
89
- @model.reflect_on_all_associations.select do |assoc|
90
- assoc.is_a?(ActiveRecord::Reflection::HasAndBelongsToManyReflection)
91
- end
83
+ @model.reflect_on_all_associations.grep(ActiveRecord::Reflection::HasAndBelongsToManyReflection)
92
84
  end
93
85
 
94
86
  # Appends an association definition to the source string
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynamicActiveModel
4
+ # Gem version, bumped by release-please
5
+ VERSION = '0.8.0'
6
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'dynamic-active-model/version'
4
+
3
5
  # DynamicActiveModel is a Ruby gem that provides automatic database discovery,
4
6
  # model creation, and relationship mapping for Rails applications.
5
7
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic-active-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-02-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord
@@ -58,6 +58,7 @@ files:
58
58
  - lib/dynamic-active-model/foreign_key.rb
59
59
  - lib/dynamic-active-model/setup.rb
60
60
  - lib/dynamic-active-model/template_class_file.rb
61
+ - lib/dynamic-active-model/version.rb
61
62
  homepage: https://github.com/dougyouch/dynamic-active-model
62
63
  licenses:
63
64
  - MIT
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
79
80
  requirements: []
80
- rubygems_version: 3.6.2
81
+ rubygems_version: 4.0.20
81
82
  specification_version: 4
82
83
  summary: Automatically discover database schemas and create ActiveRecord models with
83
84
  relationships