baseapi 0.1.19 → 0.1.20

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
  SHA1:
3
- metadata.gz: d717b23db853f03f0e050478301cae6de593aa31
4
- data.tar.gz: 3a1b5c98aeb1064cb8ff21393bf4c55a975c3b48
3
+ metadata.gz: ddb8da45b8a1dd667408550c02c42077b4f5c4c5
4
+ data.tar.gz: 110e4114ffa61e149ff2039a4cdc52e2ab248ba7
5
5
  SHA512:
6
- metadata.gz: 7823dfc05b717d03b70fc6f494f506dcf42890604e41c3bdc5b36c4cafb358cdca44592dd7ab420a91b5464b620325f8e27be8e28ee3f0a0622e104358943711
7
- data.tar.gz: e415c9b3e1bf3923c815a716d900bd5a695ead5e428c9cac5a4ed807ac26c22c058c90c6856b769898aca8838d3e2c58c789b9d6963827da8097548f10dad8a8
6
+ metadata.gz: b1f630706f818c6693b1ed6f5996ae09d2e310697f0d2a1932d03f41d7be64c33122356f10ad618ed1a3c0a19962f58de87fffc37f86659487919d65ae00128d
7
+ data.tar.gz: 22456f8d54ace03c59947314ae5a7ab5eddabccba5d70cef11695c4801b6ae68c392cdf571e627ff77d9326aaaaf96572dad99e69ea6aa05e74da205f2527530
data/README.md CHANGED
@@ -276,6 +276,43 @@ show, create, update, destroy
276
276
  }
277
277
  }
278
278
 
279
+ ### Module (0.1.20~)
280
+
281
+ If you want to create a View is also inclusive controller, please include a BaseApi.
282
+ index and show must be the process branches case of json request.
283
+
284
+ class UsersController < ApplicationController
285
+
286
+ # baseapi module
287
+ include BaseApi
288
+
289
+ def index
290
+ if request.format.json?
291
+ # json request
292
+ return render 'models.json.jbuilder'
293
+ else
294
+ # html request
295
+ end
296
+ end
297
+
298
+ def show
299
+ if request.format.json?
300
+ # json request
301
+ return render 'model.json.jbuilder'
302
+ else
303
+ # html request
304
+ end
305
+ end
306
+
307
+ # html request
308
+ def new
309
+ end
310
+
311
+ # html request
312
+ def edit
313
+ end
314
+ end
315
+
279
316
  ### reserved word (v0.1.13~)
280
317
 
281
318
  We are using the following as a reserved word.
@@ -1,6 +1,10 @@
1
1
  module BaseApi extend ActiveSupport::Concern
2
2
 
3
3
  included do
4
+ # verify the value of CSRF countermeasures for Token
5
+ # API to skip the verify_authenticity_token
6
+ skip_before_filter :verify_authenticity_token, if: :json_request?
7
+
4
8
  before_action :set_Model
5
9
  before_action :set_models, only: [:index]
6
10
  before_action :set_model, only: [:show, :create, :update, :destroy]
@@ -93,4 +97,10 @@ module BaseApi extend ActiveSupport::Concern
93
97
  end
94
98
  return true
95
99
  end
100
+
101
+ # is json request
102
+ # @return bool
103
+ def json_request?
104
+ request.format.json?
105
+ end
96
106
  end
@@ -1,3 +1,3 @@
1
1
  module Baseapi
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.20"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baseapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moriyuki Arakawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-06 00:00:00.000000000 Z
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler