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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 057373b968952b2e2994e96e73617371a1ee8bb1f1169baa674df23de6009d77
4
- data.tar.gz: d7773ccff492ddfcd89696502d82a041aafef09d4fbaca3188b73e4faeb00d5c
3
+ metadata.gz: 638d5d849cf0f6a3b456c7fc6d1906263df776333bc754f38553aa45162a7be3
4
+ data.tar.gz: 87bb5dcd4f65d3539d60bd80103be7d4dbafbf3f90c29200dadd144743edd19f
5
5
  SHA512:
6
- metadata.gz: 2e8d2da4e111a9424a439dda5b3a997947981cf5895d56790d325d3c9b8afe70b53fd57a9f550fb5978081df3fec4ab7f047afacd5de52d93fe199a2b7ff3494
7
- data.tar.gz: 19b9c83fd9846aa1f445eadc36943875b4fa96ec7648ec7ffbaa07d08ff7c5a9b370ca8c4ab3ccaab17ad83a611a1105ee3fefacc635c7fc3eba398d94fe4651
6
+ metadata.gz: e784ebdc889cf8c89e6fce1916e001d30c3a160b7093e5ff2de4903de1b86a577794dace867353d22d63d7caa4992e4e2ae95c1e4daf515395303eb032e84500
7
+ data.tar.gz: e1eb1f492d928d9c062676f72621b753fbdbf1fbe22ca3b04c920808ed51b82f1dd96859852fcce0c202f7d3276079ccc96524cbfcf76e897aff030563f16be9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.7
1
+ 0.8.9
@@ -1,6 +1,6 @@
1
1
  <tr>
2
2
  <td>
3
- <% if route[:route].name && route[:verb] == "GET" && route[:matches_params] %>
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(from_get_recordset: false)
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
- # Delegate to the recordset's model, if it's defined. This option prevents infinite recursion.
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(from_get_recordset: true))
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.7
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-14 00:00:00.000000000 Z
11
+ date: 2023-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails