jsonapi_compliable 0.11.8 → 0.11.10

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
  SHA1:
3
- metadata.gz: a845c1141c0c2a6bde9e63207a6937f5bda4f592
4
- data.tar.gz: 6db8101f04fde4fad38fed98612a2e90facc4937
3
+ metadata.gz: c65b22ee08192e29950054add88f472e77132860
4
+ data.tar.gz: e675a96ad08246f8264df2ac265ffeab5e648af1
5
5
  SHA512:
6
- metadata.gz: 06a6ba4c9abefc42659cdb8f1984517c7a7a30d41b83463b3dcd2cc3b996e935f3d1ccb0b267221fbeba692d3b86ba42ed73d6b5374d9da68a7441c69b613c0d
7
- data.tar.gz: 87a7f332b4c57867d30cace428761a428179e23b921e9150997407a0f5723e31d93e603b2e0759692873ef72ebada4504ad3fbd8f9b78e8f248fadb9872713cd
6
+ metadata.gz: e912049b53c80808cb5cb54203e86c7594625b18adf8a5d5103663654374f1e2145c66d03d5b7ceb7572929285cdc15578a0b3dc5aaee8a22c7036a48d04c5a3
7
+ data.tar.gz: c9aa189b04542dbfa114f19d91741c2ecf986b87c1ffedc0865c127c2add5bd59942addbfe0e21a749a69a2bc2ebca7763fd8a5608bd4898a52ae4bca5d43340
data/Appraisals CHANGED
@@ -5,7 +5,7 @@ appraise "rails-4" do
5
5
  end
6
6
 
7
7
  appraise "rails-5" do
8
- gem "rails", "~> 5.0"
8
+ gem "rails", "~> 5.2"
9
9
  gem 'jsonapi-rails', '~> 0.3.1', require: 'jsonapi/rails'
10
10
  gem 'rspec-rails'
11
11
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.0"
5
+ gem "rails", "~> 5.2"
6
6
  gem "jsonapi-rails", "~> 0.3.1", :require => "jsonapi/rails"
7
7
  gem "rspec-rails"
8
8
 
@@ -33,6 +33,7 @@ JsonapiSpecHelpers::Payload.register(:<%= file_name %>) do
33
33
  <%- attributes.each do |a| -%>
34
34
  <%- type = a.type == :boolean ? [TrueClass, FalseClass] : a.type.to_s.classify -%>
35
35
  <%- type = String if a.type == :text -%>
36
+ <%- type = Float if a.type == :decimal -%>
36
37
  key(:<%= a.name %>, <%= type %>)
37
38
  <%- end -%>
38
39
  end
@@ -130,11 +130,31 @@ module JsonapiCompliable
130
130
  # @api private
131
131
  # @yieldreturn Code to run within the current context
132
132
  def wrap_context
133
- jsonapi_resource.with_context(self, action_name.to_sym) do
133
+ jsonapi_resource.with_context(jsonapi_context, action_name.to_sym) do
134
134
  yield
135
135
  end
136
136
  end
137
137
 
138
+ # Override if you'd like the "context" to be something other than
139
+ # an instance of this class.
140
+ # In Rails, context is the controller instance.
141
+ #
142
+ # @example Overriding
143
+ # # within your controller
144
+ # def jsonapi_context
145
+ # current_user
146
+ # end
147
+ #
148
+ # # within a resource
149
+ # default_filter :by_user do |scope, context|
150
+ # scope.where(user_id: context.id)
151
+ # end
152
+ #
153
+ # @return the context object you'd like
154
+ def jsonapi_context
155
+ self
156
+ end
157
+
138
158
  # Use when direct, low-level access to the scope is required.
139
159
  #
140
160
  # @example Show Action
@@ -16,8 +16,8 @@ module JsonapiCompliable
16
16
  extra_fields = query_hash[:extra_fields]
17
17
 
18
18
  # Ensure fields doesnt clobber extra fields
19
- if extra_fields.any? && fields.any?
20
- extra_fields.each { |k,v| fields[k] = fields[k].to_a + v }
19
+ extra_fields.each do |k,v|
20
+ fields[k] = fields[k] + v if fields[k]
21
21
  end
22
22
 
23
23
  options = {}
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.11.8"
2
+ VERSION = "0.11.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.8
4
+ version: 0.11.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-05-10 00:00:00.000000000 Z
12
+ date: 2018-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable