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 +4 -4
- data/README.md +37 -0
- data/lib/baseapi/app/controllers/concerns/base_api.rb +10 -0
- data/lib/baseapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddb8da45b8a1dd667408550c02c42077b4f5c4c5
|
4
|
+
data.tar.gz: 110e4114ffa61e149ff2039a4cdc52e2ab248ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/baseapi/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|