rest_rails 0.9.0 → 1.0.5
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: e44dc67a7765b180d91f76fb2c06adce63351171b59f5e9e9d9fff357a3ea8ce
|
4
|
+
data.tar.gz: cd7e5c02ad8e51b67cdf62a710ba7cc61c3f2c0d8e4d39f0a73932efe9d124fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b0e8395ce42d7046cdf727331e394a4025f64db4ad2471f8aa405f74fb136ff2bb89f6a55735f049ff50e375a0f4c5a1fbcf8f8a83020b084f62b066de900e
|
7
|
+
data.tar.gz: db74177843f17a46787af716af6cfc5514ed743b1020fa6fafe2c58adbff6f82d957595b0c1fc85c22ca5662dfe56c12d194b266de0d004def625aa1812b9d1e
|
@@ -61,12 +61,27 @@ module RestRails
|
|
61
61
|
table = ar_object.class.table_name.to_sym
|
62
62
|
cols = ar_object.class.column_names.map(&:to_sym)
|
63
63
|
cols += attachments_for(ar_object) if RestRails.active_storage_attachments
|
64
|
+
cols += nested_attributes_for(ar_object) unless ar_object.class.nested_attributes_options.blank?
|
64
65
|
|
65
66
|
return cols if RestRails.permit == :all || RestRails.permit[table] == :all
|
66
67
|
|
67
68
|
cols.select{|x| RestRails.permit[table].include?(x) }
|
68
69
|
end
|
69
70
|
|
71
|
+
def nested_attributes_for(ar_object)
|
72
|
+
tables = ar_object.class.nested_attributes_options.keys
|
73
|
+
|
74
|
+
tables.map do |x|
|
75
|
+
cols = x.to_s.classify.constantize.column_names.map(&:to_sym)
|
76
|
+
key = "#{x}_attributes".to_sym
|
77
|
+
cols.delete(:id)
|
78
|
+
|
79
|
+
{key => cols}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
70
85
|
# ==========================================================================
|
71
86
|
# OTHER HELPERS
|
72
87
|
# ==========================================================================
|
data/lib/rest_rails.rb
CHANGED
@@ -12,4 +12,11 @@ module RestRails
|
|
12
12
|
def self.configure
|
13
13
|
yield self
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.path_for(ar_obj)
|
17
|
+
root_path = RestRails::Engine.mounted_path
|
18
|
+
table = ar_obj.class.table_name
|
19
|
+
return "#{root_path}/#{table}" if ar_obj.id.nil?
|
20
|
+
return "#{root_path}/#{table}/#{ar_obj.id}"
|
21
|
+
end
|
15
22
|
end
|
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: 0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rivas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|