dynamic-active-model 1.2.0 → 1.3.1
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 +4 -4
- data/lib/dynamic-active-model/setup.rb +7 -15
- data/lib/dynamic-active-model/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52adb8ab9614c47a5bdd4fe87a8ac14078684b37dc4caff9baebe2fd8bb65718
|
|
4
|
+
data.tar.gz: 28fc1d420cd7d5a2f08c45213bfc54b3c8d8327db757d502c1eab4cfbedbb896
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fab444d391e6c7082692281318750004fb428f8b6e71b312abe46932987481c0f2fbd1e9a01256fec548fb6fbff28fcc0c3a0c9ea04183628a16285e8e3cd454
|
|
7
|
+
data.tar.gz: 7c9fd888c54eaf0b2f92c72e98d8e8580fef3f7af0d61c068b71bd94f424378cc27ea9bd0ac87b5edbab66034953acb173fd95c59d7eb760754693be6a40f63e
|
|
@@ -115,9 +115,7 @@ module DynamicActiveModel
|
|
|
115
115
|
# Adds a single table to the skip list
|
|
116
116
|
# @param table [String] Table to skip
|
|
117
117
|
def skip_table(table)
|
|
118
|
-
|
|
119
|
-
config[:skip_tables] << table
|
|
120
|
-
redefine_class_method(:dynamic_active_model_config, config)
|
|
118
|
+
update_config(:skip_tables, skip_tables + [table])
|
|
121
119
|
end
|
|
122
120
|
|
|
123
121
|
# Sets or gets the custom relationships
|
|
@@ -133,20 +131,15 @@ module DynamicActiveModel
|
|
|
133
131
|
# @param foreign_key [String] Name of the foreign key column
|
|
134
132
|
# @param relationship_name [String] Name for the relationship
|
|
135
133
|
def foreign_key(table_name, foreign_key, relationship_name)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
current_relationships[table_name] ||= {}
|
|
139
|
-
current_relationships[table_name][foreign_key] = relationship_name
|
|
140
|
-
redefine_class_method(:dynamic_active_model_config, config)
|
|
134
|
+
table_relationships = relationships.fetch(table_name, {}).merge(foreign_key => relationship_name)
|
|
135
|
+
update_config(:relationships, relationships.merge(table_name => table_relationships))
|
|
141
136
|
end
|
|
142
137
|
|
|
143
138
|
# Sets a custom class name for a table
|
|
144
139
|
# @param table_name [String] Name of the table
|
|
145
140
|
# @param class_name [String] Class name to use for the table's model
|
|
146
141
|
def table_class_name(table_name, class_name)
|
|
147
|
-
|
|
148
|
-
config[:table_class_names][table_name.to_s] = class_name
|
|
149
|
-
redefine_class_method(:dynamic_active_model_config, config)
|
|
142
|
+
update_config(:table_class_names, table_class_names.merge(table_name.to_s => class_name))
|
|
150
143
|
end
|
|
151
144
|
|
|
152
145
|
# Gets the custom class names by table name
|
|
@@ -208,13 +201,12 @@ module DynamicActiveModel
|
|
|
208
201
|
"pass a Symbol instead (connection_options #{options.to_sym.inspect})"
|
|
209
202
|
end
|
|
210
203
|
|
|
211
|
-
# Stores a single configuration value
|
|
204
|
+
# Stores a single configuration value in a new config hash. The current hash (and
|
|
205
|
+
# any nested values) may be shared with a parent class, so it is never changed.
|
|
212
206
|
# @param key [Symbol] Configuration key
|
|
213
207
|
# @param value [Object] Configuration value
|
|
214
208
|
def update_config(key, value)
|
|
215
|
-
|
|
216
|
-
config[key] = value
|
|
217
|
-
redefine_class_method(:dynamic_active_model_config, config)
|
|
209
|
+
redefine_class_method(:dynamic_active_model_config, dynamic_active_model_config.merge(key => value))
|
|
218
210
|
end
|
|
219
211
|
end
|
|
220
212
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dynamic-active-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Doug Youch
|
|
@@ -27,16 +27,22 @@ dependencies:
|
|
|
27
27
|
name: inheritance-helper
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '0.2'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '2'
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
37
|
-
- - "
|
|
40
|
+
- - ">="
|
|
38
41
|
- !ruby/object:Gem::Version
|
|
39
42
|
version: '0.2'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '2'
|
|
40
46
|
description: Dynamic Active Model automatically discovers database schemas and creates
|
|
41
47
|
ActiveRecord models without manual class definitions. It detects and configures
|
|
42
48
|
relationships (belongs_to, has_many, has_one, has_and_belongs_to_many) based on
|
|
@@ -73,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
73
79
|
requirements:
|
|
74
80
|
- - ">="
|
|
75
81
|
- !ruby/object:Gem::Version
|
|
76
|
-
version: '3.
|
|
82
|
+
version: '3.3'
|
|
77
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
84
|
requirements:
|
|
79
85
|
- - ">="
|