rest_framework 0.8.7 → 0.8.8

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: 057373b968952b2e2994e96e73617371a1ee8bb1f1169baa674df23de6009d77
4
- data.tar.gz: d7773ccff492ddfcd89696502d82a041aafef09d4fbaca3188b73e4faeb00d5c
3
+ metadata.gz: fdf558252b808d2206ef0998357d81ccab85d81da850e8d3fb6b881c8a6919b8
4
+ data.tar.gz: 11bb1d4d4aeee303e691001694a9dc637b78f3f6b0a554f5945ee0ccd1ce0227
5
5
  SHA512:
6
- metadata.gz: 2e8d2da4e111a9424a439dda5b3a997947981cf5895d56790d325d3c9b8afe70b53fd57a9f550fb5978081df3fec4ab7f047afacd5de52d93fe199a2b7ff3494
7
- data.tar.gz: 19b9c83fd9846aa1f445eadc36943875b4fa96ec7648ec7ffbaa07d08ff7c5a9b370ca8c4ab3ccaab17ad83a611a1105ee3fefacc635c7fc3eba398d94fe4651
6
+ metadata.gz: a62aa886dac641f1635f41c8dfa659c3ddbc706d594ec3e58182241493b7294c58623be1aaa01010ec5f7473c6a64c887a582f1205ab560a1d05ddde00fe1a14
7
+ data.tar.gz: e7e4f071815949810711be85bef6a5499f78fdf81f8cd872b7834e853f463313403f45877c0ae2f979eda23b6f33c55e768ce34941095e66ea3f4edbc0886d56
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.7
1
+ 0.8.8
@@ -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.8
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails