rest_framework 0.0.3 → 0.0.5

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: 573511c8fd193f39ad79529ae7af61b890536bc1ba8d033a1b7e1d9ee8825ed7
4
- data.tar.gz: a46c43aaf66552a5fe5ff4f50d214dda32ce7777e1994fbe5d0fdcf8018b279f
3
+ metadata.gz: 6d0230ba5202225c71130921355680792e1907f593fa5c664d1d1bc862076d18
4
+ data.tar.gz: 65fe4ade26bdeadc825261e568de4947ef6440e07a2783241eecaec9147dcf16
5
5
  SHA512:
6
- metadata.gz: 626f03645ce25dbd70fd51c19750edd846e864ac16037ba07f9e93d9525c672f14a1c5b2b8a49db24242117e538d87ce33363a7e0649a9dc3e49eedd4dfd1f69
7
- data.tar.gz: ed442d6cf44fff1e36e211c69279372efd5eebf4a74d1ab4721ef0bc6f10bb5a81a7252b857de92224c547848e9236aa9b56e28b33d6589748ce938f4b143e47
6
+ metadata.gz: d7b880340dd0b3b784e366abae39286632d3d36e784a792f76e74181e6a39a364cbcdb6d206893ae759f249f3cec559fe741c413b95ed741f359700ffdc4652a
7
+ data.tar.gz: 904b8f2cd4390e7d912b63795e09c5cdbbfba7972fdcf6131c680e73a3d214eb88569ade00ce87da4ef9fa5a5b505877a5edd1c35c26f7431cb69c504381a269
@@ -2,7 +2,6 @@
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
3
3
  <%= csrf_meta_tags %>
4
4
  <%= csp_meta_tag rescue nil %>
5
- <%= favicon_link_tag 'rest_framework_favicon.ico' rescue nil %>
6
5
 
7
6
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
8
7
  <style>
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.5
@@ -2,7 +2,6 @@ module RESTFramework
2
2
 
3
3
  # This module provides helpers for mixin `ClassMethods` submodules.
4
4
  module ClassMethodHelpers
5
-
6
5
  # This helper assists in providing reader interfaces for mixin properties.
7
6
  def _restframework_attr_reader(property, default: nil)
8
7
  method = <<~RUBY
@@ -31,26 +30,22 @@ module RESTFramework
31
30
  module ClassMethods
32
31
  extend ClassMethodHelpers
33
32
 
34
- # Interface for getting class-level instance/class variables.
33
+ # Interface for getting class-level instance/class variables. Note: we check if they are
34
+ # defined first rather than rescuing NameError to prevent uninitialized variable warnings.
35
35
  private def _restframework_try_class_level_variable_get(name, default: nil)
36
- begin
37
- v = instance_variable_get("@#{name}")
36
+ instance_variable = "@#{name}"
37
+ if self.instance_variable_defined?(instance_variable)
38
+ v = self.instance_variable_get(instance_variable)
38
39
  return v unless v.nil?
39
- rescue NameError
40
40
  end
41
- begin
42
- v = class_variable_get("@@#{name}")
41
+ class_variable = "@@#{name}"
42
+ if self.class_variable_defined?(class_variable)
43
+ v = self.class_variable_get(class_variable)
43
44
  return v unless v.nil?
44
- rescue NameError
45
45
  end
46
46
  return default
47
47
  end
48
48
 
49
- # Interface for registering exceptions handlers.
50
- # private def _restframework_register_exception_handlers
51
- # rescue_from
52
- # end
53
-
54
49
  _restframework_attr_reader(:singleton_controller)
55
50
  _restframework_attr_reader(:extra_actions, default: {})
56
51
  _restframework_attr_reader(:template_logo_text, default: 'Rails REST Framework')
@@ -94,7 +89,7 @@ module RESTFramework
94
89
 
95
90
  # serialize
96
91
  if self.respond_to?(:get_model_serializer_config, true)
97
- serialized_payload = payload.to_json(**self.get_model_serializer_config)
92
+ serialized_payload = payload.to_json(self.get_model_serializer_config)
98
93
  else
99
94
  serialized_payload = payload.to_json
100
95
  end
@@ -50,7 +50,7 @@ module RESTFramework
50
50
 
51
51
  # Get a list of fields for the current action.
52
52
  def get_fields
53
- return @fields if @fields
53
+ return @fields if instance_variable_defined?(:@fields) && @fields
54
54
 
55
55
  # index action should use list_fields
56
56
  name = (action_name == 'index') ? 'list' : action_name
@@ -59,9 +59,8 @@ module RESTFramework
59
59
  @fields = self.class.send("#{name}_fields")
60
60
  rescue NameError
61
61
  end
62
- @fields ||= self.class.fields || []
63
62
 
64
- return @fields
63
+ return @fields ||= self.class.fields || []
65
64
  end
66
65
 
67
66
  # Get a configuration passable to `as_json` for the model.
@@ -112,7 +111,7 @@ module RESTFramework
112
111
 
113
112
  # Internal interface for get_model, protecting against infinite recursion with get_recordset.
114
113
  def _get_model(from_internal_get_recordset: false)
115
- return @model if @model
114
+ return @model if instance_variable_defined?(:@model) && @model
116
115
  return self.class.model if self.class.model
117
116
  unless from_internal_get_recordset # prevent infinite recursion
118
117
  recordset = self._get_recordset(from_internal_get_model: true)
@@ -127,7 +126,7 @@ module RESTFramework
127
126
 
128
127
  # Internal interface for get_recordset, protecting against infinite recursion with get_model.
129
128
  def _get_recordset(from_internal_get_model: false)
130
- return @recordset if @recordset
129
+ return @recordset if instance_variable_defined?(:@recordset) && @recordset
131
130
  return self.class.recordset if self.class.recordset
132
131
  unless from_internal_get_model # prevent infinite recursion
133
132
  model = self._get_model(from_internal_get_recordset: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory N. Schmit
@@ -33,8 +33,6 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - LICENSE
35
35
  - README.md
36
- - app/assets/images/rest_framework_favicon.ico
37
- - app/assets/stylesheets/rest_framework.css
38
36
  - app/views/layouts/rest_framework.html.erb
39
37
  - app/views/rest_framework/_head.html.erb
40
38
  - app/views/rest_framework/_routes.html.erb
@@ -1 +0,0 @@
1
- h1, h2, h3, h4, h5, h6 { width: 100%; }