jsonapi-utils 0.6.0.beta → 0.6.0

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: 53c3ddcb7fbfb8b20eb1bb345d044a99b8e88c48
4
- data.tar.gz: 6cf60b61e4d16acdbb22165a38c603809ae47689
3
+ metadata.gz: 0efb4509e06e84372f0c8eb578bda2ee0c1996d7
4
+ data.tar.gz: 0c6ed180ee94395c772150647a96caeb4067c08e
5
5
  SHA512:
6
- metadata.gz: 6d0674d2ddd8e84d84eb190cfa4c2a93b447ed783e06598b46e139e6a6d0771cd246fab0fb3ad2005c9c06abe3336b7a45a12ddfd98d796c21705233cb20b9e5
7
- data.tar.gz: d4fb458df88ddf11f719317e28c12387227313f20585325d2e33f858fb1f557a07938d8e57ae313a0d53006781053e7699a7213692a95877764327e4e9aa638a
6
+ metadata.gz: 0aa6e06f2971a5ef29a353950c258ee883ddcf52d7398460edf5b3da622618c7cd7afd27d42c74df729cf03dedc56a0e0b7fbd6ed2a5a4ecad063c7a90007d67
7
+ data.tar.gz: 88f627109d057c93192792df420ddd6948e332a98ca4f98d97a6772bbbaa319a0c5b139cb1b3c9c706eda7023fa84f7f0171c41833a018ca3a4bc3117349c133
data/README.md CHANGED
@@ -283,12 +283,12 @@ JU brings helper methods as a shortcut to get values from permitted params based
283
283
 
284
284
  After installing the gem you simply need to:
285
285
 
286
- 1. Include its module (`include JSONAPI::Utils`) in controller (eg. `BaseController`);
287
- 2. Define the resources for your models;
288
- 3. Define routes;
289
- 4. Use JU's render/helper methods.
286
+ 1. Include the gem's module (`include JSONAPI::Utils`) in a controller (eg. `BaseController`);
287
+ 2. Define the resources which will be exposed via REST API;
288
+ 3. Define the application's routes;
289
+ 4. Use JSONAPI Utils' helper methods (eg. renders, formatters, params helpers etc).
290
290
 
291
- Ok, it's time for a more complete example. Let's say we have a Rails application for a super simple blog:
291
+ Ok, now it's time to start our complete example. So, let's say we have a Rails application for a super simple blog:
292
292
 
293
293
  ### Models
294
294
 
@@ -299,7 +299,7 @@ class User < ActiveRecord::Base
299
299
  validates :first_name, :last_name, presence: true
300
300
  end
301
301
 
302
- # app/models/user.rb
302
+ # app/models/post.rb
303
303
  class Post < ActiveRecord::Base
304
304
  belongs_to :author, class_name: 'User', foreign_key: 'user_id'
305
305
  validates :title, :body, presence: true
@@ -308,7 +308,7 @@ end
308
308
 
309
309
  ### Resources
310
310
 
311
- Here is where we define how the models are exposed as resource on the API:
311
+ Here is where we define how our models are exposed as resources on the API:
312
312
 
313
313
  ```ruby
314
314
  # app/resources/user_resource.rb
@@ -331,20 +331,19 @@ end
331
331
 
332
332
  ### Routes & Controllers
333
333
 
334
- Let's define the routes using the `jsonapi_resources` and `jsonapi_links` methods provided by JR:
334
+ Let's define the routes using the `jsonapi_resources` method provided by JR:
335
335
 
336
336
  ```ruby
337
337
  Rails.application.routes.draw do
338
338
  jsonapi_resources :users do
339
339
  jsonapi_resources :posts
340
- jsonapi_links :posts
341
340
  end
342
341
  end
343
342
  ```
344
343
 
345
344
  In controllers we just need to include the `JSONAPI::Utils` module.
346
345
 
347
- > Note: you may want to define some default rendering like the below example using `jsonapi_render_not_found` for when ActiveRecord doesn't find a record.
346
+ > Note: some default rendering can be set like the below example where `jsonapi_render_not_found` is used when a record is not found in the database.
348
347
 
349
348
  ```ruby
350
349
  # app/controllers/base_controller.rb
@@ -355,7 +354,7 @@ class BaseController < ActionController::Base
355
354
  end
356
355
  ```
357
356
 
358
- Finally, having inhirited `JSONAPI::Utils` methods from the `BaseController` we could write our actions as the following:
357
+ With the helper methods inhirited from `JSONAPI::Utils` in our `BaseController`, now it's all about to write our actions like the following:
359
358
 
360
359
  ```ruby
361
360
  # app/controllers/users_controller.rb
@@ -22,7 +22,7 @@ module JSONAPI
22
22
  private
23
23
 
24
24
  def active_record_obj?(data)
25
- data.is_a?(ActiveRecord::Base)|| data.singleton_class.include?(ActiveModel::Model)
25
+ defined?(ActiveRecord::Base) && (data.is_a?(ActiveRecord::Base) || data.singleton_class.include?(ActiveModel::Model))
26
26
  end
27
27
 
28
28
  def build_response_document(records, options)
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Utils
3
- VERSION = '0.6.0.beta'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.beta
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Guedes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-03-30 00:00:00.000000000 Z
12
+ date: 2017-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-resources
@@ -193,12 +193,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
- - - ">"
196
+ - - ">="
197
197
  - !ruby/object:Gem::Version
198
- version: 1.3.1
198
+ version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.6.7
201
+ rubygems_version: 2.6.11
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: JSON::Utils is a simple way to get a full-featured JSON API serialization