Module: Starter::Templates::Endpoints
- Included in:
- Builder
- Defined in:
- lib/starter/builder/templates/endpoints.rb
Overview
defining the endpoints -> http methods of a resource
Instance Method Summary collapse
- #crud ⇒ Object
-
#get_all ⇒ Object
GET.
- #get_all_spec ⇒ Object
-
#post ⇒ Object
available API/HTTP methods POST.
-
#post_spec ⇒ Object
request specs shared examples.
- #singular_one ⇒ Object
Instance Method Details
#crud ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/starter/builder/templates/endpoints.rb', line 7 def crud %i[ post get_all get_specific put_specific patch_specific delete_specific ] end |
#get_all ⇒ Object
GET
42 43 44 45 46 47 48 49 |
# File 'lib/starter/builder/templates/endpoints.rb', line 42 def get_all " desc 'get all of #{resource.pluralize}', is_array: true get do # your code goes here end" end |
#get_all_spec ⇒ Object
80 81 82 |
# File 'lib/starter/builder/templates/endpoints.rb', line 80 def get_all_spec "it_behaves_like 'GET all'" end |
#post ⇒ Object
available API/HTTP methods POST
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/starter/builder/templates/endpoints.rb', line 30 def post " desc 'create #{resource.singularize}' params do # TODO: specify the parameters end post do # your code goes here end" end |
#post_spec ⇒ Object
request specs shared examples
76 77 78 |
# File 'lib/starter/builder/templates/endpoints.rb', line 76 def post_spec "it_behaves_like 'POST', params: {}" end |
#singular_one ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/starter/builder/templates/endpoints.rb', line 18 def singular_one %i[ post get_one put_one patch_one delete_one ] end |