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
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/starter/builder/templates/endpoints.rb', line 44 def get_all " desc 'get all of #{resource.pluralize}' do is_array true tags %w[#{resource.singularize}] end get do # your code goes here end" end |
#get_all_spec ⇒ Object
90 91 92 |
# File 'lib/starter/builder/templates/endpoints.rb', line 90 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 40 41 |
# File 'lib/starter/builder/templates/endpoints.rb', line 30 def post " desc 'create #{resource.singularize}' do tags %w[#{resource.singularize}] end params do # TODO: specify the parameters end post do # your code goes here end" end |
#post_spec ⇒ Object
request specs shared examples
86 87 88 |
# File 'lib/starter/builder/templates/endpoints.rb', line 86 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 |