rest_framework 0.8.7 → 0.8.9
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/VERSION +1 -1
- data/app/views/rest_framework/_route.html.erb +1 -1
- data/lib/rest_framework/controller_mixins/models.rb +3 -15
- data/lib/rest_framework/errors.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 638d5d849cf0f6a3b456c7fc6d1906263df776333bc754f38553aa45162a7be3
|
4
|
+
data.tar.gz: 87bb5dcd4f65d3539d60bd80103be7d4dbafbf3f90c29200dadd144743edd19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e784ebdc889cf8c89e6fce1916e001d30c3a160b7093e5ff2de4903de1b86a577794dace867353d22d63d7caa4992e4e2ae95c1e4daf515395303eb032e84500
|
7
|
+
data.tar.gz: e1eb1f492d928d9c062676f72621b753fbdbf1fbe22ca3b04c920808ed51b82f1dd96859852fcce0c202f7d3276079ccc96524cbfcf76e897aff030563f16be9
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.9
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<tr>
|
2
2
|
<td>
|
3
|
-
<% if route[:
|
3
|
+
<% if route[:verb] == "GET" && route[:matches_params] %>
|
4
4
|
<%= link_to route[:relative_path], @route_props[:with_path_args].call(route[:route]) %>
|
5
5
|
<% else %>
|
6
6
|
<%= route[:relative_path] %>
|
@@ -71,7 +71,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
71
71
|
IGNORE_VALIDATORS_WITH_KEYS = [:if, :unless].freeze
|
72
72
|
|
73
73
|
# Get the model for this controller.
|
74
|
-
def get_model
|
74
|
+
def get_model
|
75
75
|
return @model if @model
|
76
76
|
return (@model = self.model) if self.model
|
77
77
|
|
@@ -81,19 +81,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
81
81
|
rescue NameError
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
unless from_get_recordset
|
86
|
-
# Instantiate a new controller to get the recordset.
|
87
|
-
controller = self.new
|
88
|
-
controller.request = ActionController::TestRequest.new
|
89
|
-
controller.params = {}
|
90
|
-
|
91
|
-
if (recordset = controller.get_recordset)
|
92
|
-
return @model = recordset.klass
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
return nil
|
84
|
+
raise RESTFramework::UnknownModelError, self
|
97
85
|
end
|
98
86
|
|
99
87
|
# Override `get_label` to include ActiveRecord i18n-translated column names.
|
@@ -488,7 +476,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
488
476
|
return (@recordset = self.class.recordset) if self.class.recordset
|
489
477
|
|
490
478
|
# If there is a model, return that model's default scope (all records by default).
|
491
|
-
if (model = self.class.get_model
|
479
|
+
if (model = self.class.get_model)
|
492
480
|
return @recordset = model.all
|
493
481
|
end
|
494
482
|
|
@@ -13,3 +13,19 @@ class RESTFramework::NilPassedToAPIResponseError < RESTFramework::Error
|
|
13
13
|
MSG
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
class RESTFramework::UnknownModelError < RESTFramework::Error
|
18
|
+
def initialize(controller_class)
|
19
|
+
super()
|
20
|
+
@controller_class = controller_class
|
21
|
+
end
|
22
|
+
|
23
|
+
def message
|
24
|
+
return <<~MSG.split("\n").join(" ")
|
25
|
+
The model class for `#{@controller_class}` could not be determined. Any controller that
|
26
|
+
includes `RESTFramework::BaseModelControllerMixin` (directly or indirectly) must either set
|
27
|
+
the `model` attribute on the controller, or the model must be deducible from the controller
|
28
|
+
name (e.g., `UsersController` could resolve to the `User` model).
|
29
|
+
MSG
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory N. Schmit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|