baseapi 0.2.5 → 0.2.6
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 +16 -19
- data/lib/baseapi/app/controllers/base_api_controller.rb +0 -1
- 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: b486cc640688c880add31f0b1df884a6d4081d6f
|
4
|
+
data.tar.gz: 9f5b742b010b10813ecd0e13597b6e4a89d16788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba207bcdb7d590eca91a3a549bd25067a9395a29eec03f2b5d6934a0f0e241192e86fb2fd04d92aaed60a5b5611237d442ec43a4733cff44115745fd7045641e
|
7
|
+
data.tar.gz: 33e784e1606e9dab1fb1d93fd11ffe1b3c3079f35f0d8b7692d8f3357f71c26667343ce386c117e29c1416845027b08403967263cea6af4af9b6c3ce9c0b8fbc
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Baseapi
|
2
2
|
|
3
|
-
|
4
|
-
We only define the empty Controller and Model for us to define the CRUD in.
|
3
|
+
Restful API Controller can make simply by include the Baseapi module to your Controller.
|
5
4
|
|
6
5
|
## Installation
|
7
6
|
|
@@ -21,21 +20,22 @@ Or install it yourself as:
|
|
21
20
|
|
22
21
|
## Usage
|
23
22
|
|
24
|
-
Introduction create default JBuilder of view
|
23
|
+
Introduction create default JBuilder of view.
|
25
24
|
|
26
25
|
$ bundle exec baseapi setup
|
27
26
|
|
28
|
-
Create a Model (app/models/user.rb)
|
27
|
+
Create a Model (app/models/user.rb)
|
29
28
|
|
30
29
|
class User < ActiveRecord::Base
|
31
30
|
end
|
32
31
|
|
33
|
-
|
32
|
+
include the Baseapi module to Controller (app/controlers/users_controller.rb)
|
34
33
|
|
35
|
-
class UsersController <
|
34
|
+
class UsersController < ApplicationController
|
35
|
+
include BaseApi
|
36
36
|
end
|
37
37
|
|
38
|
-
Routing configuration (config/routes.rb)
|
38
|
+
Routing configuration (config/routes.rb)
|
39
39
|
|
40
40
|
constraints(:format => /json/) do
|
41
41
|
resources :users, only:[:index, :show, :create, :update, :destroy]
|
@@ -334,8 +334,7 @@ You can request as follows in doing so
|
|
334
334
|
|
335
335
|
### Override
|
336
336
|
|
337
|
-
|
338
|
-
|
337
|
+
you will be able to override the processing in the Model.
|
339
338
|
|
340
339
|
Get all
|
341
340
|
|
@@ -451,10 +450,7 @@ The short so please read the [code](https://github.com/arakawamoriyuki/baseapi/b
|
|
451
450
|
|
452
451
|
### hook action (v0.1.4~)
|
453
452
|
|
454
|
-
Controller of 'create, update, destroy' function in advance by attaching the prefix of before, you can post processing
|
455
|
-
Delete the related table or may be useful for error handling
|
456
|
-
It may be good even before_action, but you may use if you want to process in the transaction.
|
457
|
-
It is always surrounded by model of transaction.
|
453
|
+
Controller of 'create, update, destroy' function in advance by attaching the prefix of before, you can post processing.
|
458
454
|
|
459
455
|
class CompaniesController < BaseApiController
|
460
456
|
# Name Required items
|
@@ -471,7 +467,8 @@ It is always surrounded by model of transaction.
|
|
471
467
|
end
|
472
468
|
end
|
473
469
|
|
474
|
-
And if not sent the name to api in the above example, it returns an error in the json.
|
470
|
+
And if not sent the name to api in the above example, it returns an error in the json.
|
471
|
+
Message is a string that was passed to raise.
|
475
472
|
|
476
473
|
{
|
477
474
|
error: true,
|
@@ -487,18 +484,18 @@ create JBuilder of view (0.1.17)
|
|
487
484
|
|
488
485
|
Used by default [^2]
|
489
486
|
|
490
|
-
/app/views/application/
|
491
|
-
/app/views/base_api/
|
487
|
+
/app/views/application/xxx.json.jbuilder # if include BaseApi
|
488
|
+
/app/views/base_api/xxx.json.jbuilder # if extend BaseApi
|
492
489
|
|
493
490
|
but you can also make
|
494
491
|
|
495
|
-
/app/views/{models}/
|
492
|
+
/app/views/{models}/xxx.json.jbuilder
|
496
493
|
|
497
|
-
It will return to a single data (action:show,create,delete,update)
|
494
|
+
It will return to a single data (action: show, create, delete, update)
|
498
495
|
|
499
496
|
model.json.jbuilder
|
500
497
|
|
501
|
-
It will return multiple data (action:index)
|
498
|
+
It will return multiple data (action: index)
|
502
499
|
|
503
500
|
models.json.jbuilder
|
504
501
|
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moriyuki Arakawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|