arkaan 0.8.14 → 0.8.15
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/arkaan/utils/controller.rb +8 -11
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34d91dc905b5495ced602cb92395a82b64d4f4fc
|
|
4
|
+
data.tar.gz: 33cdbdfba417dd06ef9fbf595f19dbcc1c75d321
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a18aea82a1a79b5cc6d85856dea528057dce0b5b8545b5fa2dba60339a211e180e065fca25835ba55ca231b9a5151cb3548ae7a3d0172d52a0efcf9da339c24
|
|
7
|
+
data.tar.gz: c5346b5cf93ab7b6ca9432511cc2b6f2ea0677545b65e241794217bd09914d173fef7e83380ad549c2bbf7df757ca2bd5bf19b5af23d5a88d9bbac74c244ef88
|
|
@@ -93,21 +93,18 @@ module Arkaan
|
|
|
93
93
|
|
|
94
94
|
# Halts the application and creates the returned body from the parameters and the errors config file.
|
|
95
95
|
# @param status [Integer] the HTTP status to halt the application with.
|
|
96
|
-
# @param
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
url = settings.errors[field][error]
|
|
101
|
-
halt status, {status: status, field: field, error: error, docs: "#{url}#{suffix}"}.to_json
|
|
96
|
+
# @param path [String] the path in the configuration file to access the URL.
|
|
97
|
+
def custom_error(status, path)
|
|
98
|
+
route, field, error = path.split('.')
|
|
99
|
+
halt status, {status: status, field: field, error: error, docs: settings.errors[route][field][error]}.to_json
|
|
102
100
|
end
|
|
103
101
|
|
|
104
102
|
# Halts the application with a Bad Request error affecting a field of a model.
|
|
105
103
|
# @param instance [Mongoid::Document] the document having a field in error.
|
|
106
|
-
# @param
|
|
107
|
-
def model_error(instance,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
custom_error(400, field, error, suffix: suffix)
|
|
104
|
+
# @param route [String] the type of action you're currently doing (e.g: 'creation')
|
|
105
|
+
def model_error(instance, route)
|
|
106
|
+
messages = instance.errors.messages
|
|
107
|
+
custom_error(400, "#{route}.#{messages.keys.first}.#{messages[field].first}")
|
|
111
108
|
end
|
|
112
109
|
end
|
|
113
110
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: arkaan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vincent Courtois
|
|
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
250
250
|
version: '0'
|
|
251
251
|
requirements: []
|
|
252
252
|
rubyforge_project:
|
|
253
|
-
rubygems_version: 2.
|
|
253
|
+
rubygems_version: 2.5.1
|
|
254
254
|
signing_key:
|
|
255
255
|
specification_version: 4
|
|
256
256
|
summary: The model layer for my table-RPG application
|