dynamic-active-model 0.3.0 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 939a4bf825472966414c9210ace20b328cb96b3346c64c81063abf0caf2b6e88
|
4
|
+
data.tar.gz: 731d11dd2939d33a0a9425258a04c51ef1b5e3c664268fad76a4164e0a04ed69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13bbbc17ce25badff6dc5c19fb675813897d80a76b65fd4d4d52562bf7ae0051536506be6f04a293d8a31e9dc2a538649bbce7a9da07c2c19cb737f37e9d14bb
|
7
|
+
data.tar.gz: 3e3b46e5c905c588ad2d3885bf5b18843806ac61afece97c5a210440c1b6692578bf38a7109a9b45e20420d216b7b2efb0963a6f6a59ab102b2d44cf5f4f6ca3
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DynamicActiveModel
|
4
|
+
# DynamicActiveModel::DangerousAttributesPatch is used to remove dangerous attribute names
|
5
|
+
# from attribute_names method in ActiveRecord
|
6
|
+
module DangerousAttributesPatch
|
7
|
+
def self.included(base)
|
8
|
+
base.singleton_class.alias_method :original_attribute_names, :attribute_names
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
# no-doc
|
13
|
+
module ClassMethods
|
14
|
+
def attribute_names
|
15
|
+
names = original_attribute_names
|
16
|
+
names.reject! { |name| dangerous_attribute_method?(name) }
|
17
|
+
names
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -20,6 +20,7 @@ module DynamicActiveModel
|
|
20
20
|
def create!(table_name, class_name)
|
21
21
|
kls = Class.new(base_class) do
|
22
22
|
self.table_name = table_name
|
23
|
+
include DynamicActiveModel::DangerousAttributesPatch
|
23
24
|
end
|
24
25
|
@base_module.const_set(class_name, kls)
|
25
26
|
@base_module.const_get(class_name)
|
data/lib/dynamic-active-model.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# DynamicActiveModel module for create ActiveRecord models
|
4
4
|
module DynamicActiveModel
|
5
5
|
autoload :Database, 'dynamic-active-model/database'
|
6
|
+
autoload :DangerousAttributesPatch, 'dynamic-active-model/dangerous_attributes_patch'
|
6
7
|
autoload :Explorer, 'dynamic-active-model/explorer'
|
7
8
|
autoload :Factory, 'dynamic-active-model/factory'
|
8
9
|
autoload :ForeignKey, 'dynamic-active-model/foreign_key'
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- bin/dynamic-db-explorer
|
35
35
|
- lib/dynamic-active-model.rb
|
36
36
|
- lib/dynamic-active-model/associations.rb
|
37
|
+
- lib/dynamic-active-model/dangerous_attributes_patch.rb
|
37
38
|
- lib/dynamic-active-model/database.rb
|
38
39
|
- lib/dynamic-active-model/explorer.rb
|
39
40
|
- lib/dynamic-active-model/factory.rb
|