apiql 0.2.1 → 0.2.2

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: d352e5c0593440e6f860500f9aff2e02238ff4ccd4cee8d4845eb80aa2301e95
4
- data.tar.gz: 8600a0d3df1e54eac36e10d0898c151adbb53d771d2a09f50a6002899506ae28
3
+ metadata.gz: f103af812fb631ddf00a34acc478436d42d39fd1a66de8e2b0ee32a7023d159c
4
+ data.tar.gz: 2cf523c953d6ba31d3017183fe09353546a9d627869972e325342e732c7f1f6c
5
5
  SHA512:
6
- metadata.gz: '0979ad9a4921e756a9e4251fe753002db11b2a3f769bb8274e45e1c44da9df64eda69d928ec72ae0666faa5c3347d779935f55134a6279b7dcd34e8f424b4e64'
7
- data.tar.gz: 7d11f62c6ca0fee4236307a001c9038ef1e2191b72970644e90b8f6847f75f1e4b87430ded40faadddcf1bdcb6c7ec4c5d8157f9ed1265de261edf778b9fbc41
6
+ metadata.gz: 765875ac74538f510065377ffe052d0e5a75ed2b331b9883e142be064b57f76c74c9398afe4c001e3e9674a94d7844aa8e940d819f336c0589e0e13038ed7020
7
+ data.tar.gz: 4d82c9d04123de11ae47da1eaca5b0d2ecce4d212b1e828ec6b19a35f6a75e0332fae273a4c9368a9eb28494a9a64d2bceb1bf04230a7ac6899ead8d2343c035
data/README.md CHANGED
@@ -110,6 +110,10 @@ config/initializers/apiql.rb:
110
110
  class APIQL
111
111
  delegate :authorize!, to: :@context
112
112
 
113
+ class Entity
114
+ delegate :authorize!, to: :@context
115
+ end
116
+
113
117
  class Context
114
118
  def authorize!(*args)
115
119
  ability.authorize!(*args)
@@ -122,4 +126,22 @@ class APIQL
122
126
  end
123
127
  end
124
128
  end
129
+
130
+ and authorize access to every entity:
131
+
132
+ class ApplicationRecord < ActiveRecord::Base
133
+ class BaseEntity < APIQL::Entity
134
+ def initialize(object, context)
135
+ context.authorize! :read, object
136
+ super(object, context)
137
+ end
138
+ end
139
+ end
140
+
141
+ class User < ApplicationRecord
142
+ class Entity < BaseEntity
143
+ ...
144
+ end
145
+ end
146
+
125
147
  ```
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'apiql'
7
- spec.version = '0.2.1'
7
+ spec.version = '0.2.2'
8
8
  spec.authors = ['Dmitry Silchenko']
9
9
  spec.email = ['dmitry@desofto.com']
10
10
 
@@ -32,7 +32,7 @@ const APIQL = {
32
32
  params.apiql = this.hash(schema)
33
33
  }
34
34
 
35
- Vue.http.post(`${APIQL.endpoint}${endpoint}`, params)
35
+ Vue.http.post(`${APIQL.endpoint}${endpoint}`, form || params)
36
36
  .then(response => {
37
37
  resolve(response.body)
38
38
  })
@@ -313,7 +313,11 @@ class APIQL
313
313
  elsif APIQL::simple_class?(value)
314
314
  value
315
315
  else
316
- "#{value.class.name}::Entity".constantize.new(value, self).render(schema)
316
+ begin
317
+ "#{value.class.name}::Entity".constantize.new(value, self).render(schema)
318
+ rescue StandardError
319
+ nil
320
+ end
317
321
  end
318
322
  end
319
323
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Silchenko