upframework 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -8
  3. data/lib/upframework/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1acaf495ed6f2835c25eae1905515573ee647802879f43212ad934f6f3a4a3fb
4
- data.tar.gz: 670163801f3ead631d142ef5840970833f48c069ba055ed19369a8a9e08fecc7
3
+ metadata.gz: 3b9df2b3fab51ad8cd9df13ce48c23de3f7de3345a732950f1133de10468443b
4
+ data.tar.gz: e964a3112339f87964455696b87788e9fca05f75be7fbda0edc4a22a772b667d
5
5
  SHA512:
6
- metadata.gz: e6c44c39aae828c7b62cf450d47fe2d61200cc2e2e48af25c80abd6d3f631c060518b7fc15a64d912a2e3c386487a3f1b32edc6cef5bd808e22e443d5f7c863c
7
- data.tar.gz: fa64458e28228ee45cac5d922ab848962dc313f8fb6481ffeecc1bd2d549512a73a96c6946922c65ffd57ddab6b43ab86db90120fe79440376fd3d0995f32d3e
6
+ metadata.gz: 3dccc34d6735c68b9bc5ab6e0feb4084bb33ec67df5627a20e8bb6b5e4668795dbc063e399bddf03895168a51b28235b0e7b879f1ae882b4989a7f9a4a670c00
7
+ data.tar.gz: 0be54b8cad4e95f88314aa60f8ecf9e02f0482fa97f1e202edb4b96a9321beeb16c8b107f0d3245958a85f1965bd8a9944302e98733c505baecc2e9353068f95
data/README.md CHANGED
@@ -4,39 +4,86 @@ Add features on top of Rails, Especially for APIs. This was created to make stru
4
4
  #### The following features are available.
5
5
  - Creates (create, read, update, destroy) action methods for resources.
6
6
  - Has render helpers for API or socket responses. ex. Converting models to its designated serializer.
7
- - Converts snake case request params (from js standard) to underscore params (ruby standard)
7
+ - Converts snake case request params (from js standard) to underscore params (ruby standard)
8
8
  - Searches layer under app/searches. Usually used for form searches.
9
9
  - Services layer under app/services. For single responsibility domain-specific logic code.
10
10
  - Exception notifier and API error response handler.
11
11
 
12
12
  ## Basic Usage
13
- ####Controllers
13
+ #### Controllers
14
14
  ```ruby
15
- #app/controllers
15
+ # app/controllers
16
+ # create,show,update,destroy methods are available by default
16
17
  class ProjectsController < Upframework::ResourcesController
18
+ # Example of broadcasting with a serialized object using ActionCables.
19
+ def udate
20
+ super do
21
+ channel = @project.user
22
+ broadcast_serialized(channel, resource: @project, event: "Project Updated")
23
+ end
24
+ end
25
+
26
+ # Example of rendering serialized responsed. This is using fast_jsonapi serializer.
27
+ def custom_action
28
+ render_serialized @project
29
+ end
17
30
  end
18
31
  ```
19
32
 
20
- ####Searches
33
+ #### Searches
21
34
  ```ruby
22
35
  #app/searches
23
36
  class ProjectSearch < Upframework::BaseSearch
37
+ def post_initialize
38
+ @per_page = 10
39
+ @scope = Project.accessible_by(@current_ability)
40
+ end
41
+
42
+ def execute
43
+ # query logic here using scope object defined above
44
+ # by default results are paginated
45
+ end
24
46
  end
25
47
  ```
48
+ ```
49
+ #search api available in
50
+ /search?resource=Project&arg1=""&arg2=""
51
+ ```
26
52
 
27
- ####Services
53
+ #### Services
28
54
  ```ruby
29
55
  #app/services
30
- class Project::SubmitService < Upframework::BaseService
56
+ class Project::SubmitService < Upframework::BaseService
57
+ def post_initialize(id:, **attrs)
58
+ @project = Project.find(id)
59
+ end
60
+
61
+ def execute
62
+ # put main logic here
63
+ # ...
64
+ project.save
65
+ end
66
+
67
+ def result
68
+ project
69
+ end
31
70
  end
71
+
72
+ service = Project::SubmitService.run
73
+ service.result => <Project: Instance>
74
+ service.success? => true/false
32
75
  ```
33
76
 
34
- ####Routes
35
- app/services
77
+ #### Routes
36
78
  ```ruby
37
79
  #config/routes
38
80
  mount Upframework::Engine => /path
39
81
  ```
82
+ routes being available
83
+ ```
84
+ GET /search
85
+ POST /services/:service_name
86
+ ```
40
87
 
41
88
  ## Installation
42
89
  Add this line to your application's Gemfile:
@@ -1,3 +1,3 @@
1
1
  module Upframework
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upframework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - jude_cali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails