rest_rails 1.1.6 → 1.1.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15427d21d0ab69d7e0c821473a2475a4ca8259c1a423e88c92d770936264ed44
|
4
|
+
data.tar.gz: 1eccff913bb3e4d706a96160799d30f9b292fb43f63df784e44a78c739161a2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 414990b34dfbd2ae57760be6381926de28a4e59bc4ed30abd9e9e56a83e0168c28f76884cfa9f8acdabc55cd56b6e1aab9a535cf5239f3fa5254fda6ab54c429
|
7
|
+
data.tar.gz: 3bc09bedd290c23bcd917aada308a405e4c7e4f772faf863d6fbe506c759dd4cd870cce70521a3e5df047aea625cbd638310c51caff598d7ed664a20d736e70c
|
@@ -16,7 +16,7 @@ module RestRails
|
|
16
16
|
base_query = p_hash.blank? ? @model.all : @model.where(p_hash)
|
17
17
|
|
18
18
|
@objects = base_query.order(:id).limit(ppage).offset(off)
|
19
|
-
@objects.map
|
19
|
+
@objects = @objects.map{|x| standardize_json(x) }
|
20
20
|
|
21
21
|
render json: {code: 200, objects: @objects, count: @objects.count, total: @model.count}
|
22
22
|
end
|
@@ -69,10 +69,12 @@ module RestRails
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def nested_attributes_for(ar_object)
|
72
|
-
|
72
|
+
ar_model = ar_object.class
|
73
|
+
tables = ar_model.nested_attributes_options.keys
|
73
74
|
|
74
75
|
tables.map do |x|
|
75
|
-
|
76
|
+
nested_model = ar_model.reflect_on_association(x).klass
|
77
|
+
cols = nested_model.column_names.map(&:to_sym)
|
76
78
|
key = "#{x}_attributes".to_sym
|
77
79
|
cols << :_destroy
|
78
80
|
|
@@ -80,21 +82,17 @@ module RestRails
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
|
84
|
-
|
85
85
|
# ==========================================================================
|
86
86
|
# OTHER HELPERS
|
87
87
|
# ==========================================================================
|
88
88
|
|
89
89
|
def model_for(table_name)
|
90
|
-
|
91
|
-
"schema_migrations", "ar_internal_metadata"]
|
92
|
-
tables = ActiveRecord::Base.connection.tables.reject{ |x| ignored.include?(x) }
|
90
|
+
tables = ActiveRecord::Base.descendants.reject(&:abstract_class).index_by(&:table_name)
|
93
91
|
|
94
|
-
raise RestRails::Error.new "Table '#{table_name}' does not exist in your database!" unless tables.include?(table_name)
|
92
|
+
raise RestRails::Error.new "Table '#{table_name}' does not exist in your database!" unless tables.keys.include?(table_name)
|
95
93
|
|
96
94
|
# Take the tablename, and make the Model of the relative table_name
|
97
|
-
table_name
|
95
|
+
tables[table_name]
|
98
96
|
end
|
99
97
|
|
100
98
|
def verify_permitted!(table)
|
data/lib/rest_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rivas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|