wire-framework 0.1.5.2 → 0.1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app/db.rb +18 -47
- data/lib/app/render/page.rb +2 -2
- data/lib/wire.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57b6276466fdde480be64d03871a923b517ba4d5
|
4
|
+
data.tar.gz: 085314f7a229be60dfdb3ad8c8445fa4a993da23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a6db1b191dd99b39d6dd32756caf687842d3602bec051575374f8d25ad5c0c67bcd67e2be21e28bfacc9620b461515fdadbc396c9fbb98801e754a3f02f948
|
7
|
+
data.tar.gz: 3cc276cf1e8f171f1176d2d6423cd25738ca2d1506bc035bf1e9718f7a25479a36a04b09ce8bf492af4d2e69ad7e3836a736f1e428d3c8e0c12c16c91224b153
|
data/lib/app/db.rb
CHANGED
@@ -77,13 +77,6 @@ module DB
|
|
77
77
|
415
|
78
78
|
end
|
79
79
|
else
|
80
|
-
#TODO user_id needs to happen in the context
|
81
|
-
if model.respond_to? :updated_by_id
|
82
|
-
context.json[:updated_by_id] = context.user
|
83
|
-
end
|
84
|
-
if model.respond_to? :created_by_id
|
85
|
-
context.json[:created_by_id] = context.user
|
86
|
-
end
|
87
80
|
begin
|
88
81
|
instance = model.create(context.json)
|
89
82
|
instance.save
|
@@ -104,20 +97,16 @@ module DB
|
|
104
97
|
# @param [Hash] context the context for this request
|
105
98
|
# @return [Response] all objects, or status code
|
106
99
|
def self.do_read_all(context)
|
107
|
-
return 404 unless context.resource
|
108
100
|
model = context.config['models'][context.resource]
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
hash = hash[0...-1]
|
116
|
-
hash << ']'
|
117
|
-
[200, {}, hash]
|
118
|
-
else
|
119
|
-
404
|
101
|
+
return 404 unless model
|
102
|
+
hash = '[ '
|
103
|
+
model.each do |e|
|
104
|
+
hash << e.to_json
|
105
|
+
hash << ','
|
120
106
|
end
|
107
|
+
hash = hash[0...-1]
|
108
|
+
hash << ']'
|
109
|
+
[200, {}, hash]
|
121
110
|
end
|
122
111
|
|
123
112
|
# Get a specific object from the DB table
|
@@ -130,13 +119,10 @@ module DB
|
|
130
119
|
if id.eql?('new') or id.eql? 'upload'
|
131
120
|
return '{}'
|
132
121
|
end
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
return [200, {}, object.to_json]
|
137
|
-
end
|
122
|
+
object = model[id]
|
123
|
+
if object
|
124
|
+
return [200, {}, object.to_json]
|
138
125
|
end
|
139
|
-
[404, {}, []]
|
140
126
|
end
|
141
127
|
|
142
128
|
# Update a specific object in the DB table
|
@@ -145,17 +131,8 @@ module DB
|
|
145
131
|
def self.do_update(context)
|
146
132
|
model = context.config['models'][context.resource]
|
147
133
|
return 404 unless model
|
148
|
-
|
149
|
-
|
150
|
-
if model
|
151
|
-
if model.respond_to?(:updated_by_id)
|
152
|
-
context.json[:updated_by_id] = context.user
|
153
|
-
end
|
154
|
-
instance = model[id]
|
155
|
-
instance.update(context.json)
|
156
|
-
else
|
157
|
-
404
|
158
|
-
end
|
134
|
+
instance = model[context.id]
|
135
|
+
instance.update(context.json)
|
159
136
|
end
|
160
137
|
|
161
138
|
# Remove a specific object from the DB table
|
@@ -164,18 +141,12 @@ module DB
|
|
164
141
|
def self.do_delete(context)
|
165
142
|
model = context.config['models'][context.resource]
|
166
143
|
return 404 unless model
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
if instance
|
172
|
-
if instance.destroy
|
173
|
-
200
|
174
|
-
else
|
175
|
-
[500, {}, 'Failed to delete instance']
|
176
|
-
end
|
144
|
+
instance = model[context.id]
|
145
|
+
if instance
|
146
|
+
if instance.delete
|
147
|
+
200
|
177
148
|
else
|
178
|
-
|
149
|
+
[500, {}, 'Failed to delete instance']
|
179
150
|
end
|
180
151
|
else
|
181
152
|
404
|
data/lib/app/render/page.rb
CHANGED
@@ -44,7 +44,7 @@ module Render
|
|
44
44
|
# do nothing
|
45
45
|
end
|
46
46
|
else
|
47
|
-
uri += "
|
47
|
+
uri += "/#{s}"
|
48
48
|
end
|
49
49
|
temp = []
|
50
50
|
if go_ahead
|
@@ -58,7 +58,7 @@ module Render
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
message = template[
|
61
|
+
message = template['file'].render(self, hash)
|
62
62
|
if template['use_layout']
|
63
63
|
message = render_template(actions, context, $wire_templates['layout'], message)
|
64
64
|
end
|
data/lib/wire.rb
CHANGED