dynamic-active-model 0.4.3 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a429b3b45e3768028871c2e93cf4fc3a8db46fe9aec8a54f44eab46ec15583cc
4
- data.tar.gz: 7df1cd6803c0d3ba797d0cd4fb553c60c61f635eb3de0a3cd7ecce04bb49250d
3
+ metadata.gz: 6ef466cf4634fec36648e25312d9a4729988584a86cb5dfc071c49b5515a5845
4
+ data.tar.gz: 895ea1c5eb60706bbc795c75b4f15aca8e833d3cb56d390985973d4d32053e0f
5
5
  SHA512:
6
- metadata.gz: 691d8a981057bf20a08f8af91c56b72341e55785836fb63b1ec315197a4800e9d968db1577de0b2da8e23d431f10a086e37e795dff6389db7aed275947dbf55e
7
- data.tar.gz: 25e12296d9cd4069629ff0bb4cd8b62abccc89694e7c16c5fcddf1e4e7efea842f081773be4d3e6054bb3d25d67e4c548da612128db054f077d1e1c09399c725
6
+ metadata.gz: 0c2055798c8e10c2f3d1172f9b9c7d99983cd61da0a88b512528e8c43b2d309179d5cb6c15f00890c66c9fd1c29e8b1e34ed5ba3c0e0d103418f9d11b22e167a
7
+ data.tar.gz: 2d5e76d0d77276fd867b160d33ebfa59d2cb790a5968a30b8a94942fecda9aadcd6703c5b58b2d12bb5d8cd673b264ff472a00398a391f959b7670a060570f18
@@ -6,8 +6,15 @@ module DynamicActiveModel
6
6
  module DangerousAttributesPatch
7
7
  def self.included(base)
8
8
  if base.attribute_names
9
- columns_to_ignore = base.attribute_names.select { |name| base.dangerous_attribute_method?(name) }
10
- base.ignored_columns = columns_to_ignore
9
+ columns_to_ignore = base.columns.select do |column|
10
+ if column.type == :boolean
11
+ base.dangerous_attribute_method?(column.name)
12
+ base.dangerous_attribute_method?(column.name + '?')
13
+ else
14
+ base.dangerous_attribute_method?(column.name)
15
+ end
16
+ end
17
+ base.ignored_columns = columns_to_ignore.map(&:name)
11
18
  end
12
19
  end
13
20
  end
@@ -23,6 +23,7 @@ module DynamicActiveModel
23
23
  include DynamicActiveModel::DangerousAttributesPatch
24
24
  end
25
25
  @base_module.const_set(class_name, kls)
26
+ require_extension(class_name)
26
27
  @base_module.const_get(class_name)
27
28
  end
28
29
 
@@ -52,5 +53,12 @@ module DynamicActiveModel
52
53
 
53
54
  class_name
54
55
  end
56
+
57
+ def require_extension(class_name)
58
+ file = File.expand_path(DynamicActiveModel.base_models_path + '/' + class_name.underscore + '.rb')
59
+ return unless File.exist?(file)
60
+
61
+ require file
62
+ end
55
63
  end
56
64
  end
@@ -9,4 +9,12 @@ module DynamicActiveModel
9
9
  autoload :ForeignKey, 'dynamic-active-model/foreign_key'
10
10
  autoload :Associations, 'dynamic-active-model/associations'
11
11
  autoload :TemplateClassFile, 'dynamic-active-model/template_class_file'
12
+
13
+ def self.base_models_path
14
+ @base_models_path || 'app/models'
15
+ end
16
+
17
+ def self.base_models_path=(path)
18
+ @base_models_path = path
19
+ end
12
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic-active-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2023-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord