yamls 0.1.2 → 0.2.1

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +24 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +212 -2
  5. data/example/rails5/Gemfile +1 -1
  6. data/example/rails5/app/controllers/books_controller.rb +3 -5
  7. data/example/rails5/app/controllers/people_controller.rb +1 -1
  8. data/example/rails5/db/migrate/{20211031043641_create_people.rb → 20211031170917_create_people.rb} +2 -2
  9. data/example/rails5/db/schema.rb +3 -3
  10. data/example/rails5/test/controllers/books_controller_test.rb +2 -14
  11. data/example/rails5/test/controllers/people_controller_test.rb +2 -14
  12. data/example/rails5/test/fixtures/books.yml +8 -7
  13. data/example/rails5/test/fixtures/people.yml +8 -7
  14. data/example/rails6.0.0/.gitignore +33 -0
  15. data/example/rails6.0.0/.ruby-version +1 -0
  16. data/example/rails6.0.0/Gemfile +43 -0
  17. data/example/{rails5 → rails6.0.0}/README.md +0 -0
  18. data/example/rails6.0.0/Rakefile +6 -0
  19. data/example/rails6.0.0/app/channels/application_cable/channel.rb +4 -0
  20. data/example/rails6.0.0/app/channels/application_cable/connection.rb +4 -0
  21. data/example/rails6.0.0/app/controllers/application_controller.rb +2 -0
  22. data/example/rails6.0.0/app/controllers/books_controller.rb +53 -0
  23. data/example/{rails5/test/integration → rails6.0.0/app/controllers/concerns}/.keep +0 -0
  24. data/example/rails6.0.0/app/controllers/people_controller.rb +55 -0
  25. data/example/rails6.0.0/app/jobs/application_job.rb +7 -0
  26. data/example/rails6.0.0/app/mailers/application_mailer.rb +4 -0
  27. data/example/rails6.0.0/app/models/application_record.rb +3 -0
  28. data/example/rails6.0.0/app/models/book.rb +2 -0
  29. data/example/rails6.0.0/app/models/concerns/.keep +0 -0
  30. data/example/rails6.0.0/app/models/person.rb +2 -0
  31. data/example/rails6.0.0/app/parameters/column.yml +15 -0
  32. data/example/rails6.0.0/app/views/layouts/mailer.html.erb +13 -0
  33. data/example/rails6.0.0/app/views/layouts/mailer.text.erb +1 -0
  34. data/example/rails6.0.0/bin/bundle +114 -0
  35. data/example/rails6.0.0/bin/rails +9 -0
  36. data/example/rails6.0.0/bin/rake +9 -0
  37. data/example/rails6.0.0/bin/setup +33 -0
  38. data/example/rails6.0.0/bin/spring +17 -0
  39. data/example/rails6.0.0/config/application.rb +37 -0
  40. data/example/rails6.0.0/config/boot.rb +4 -0
  41. data/example/rails6.0.0/config/cable.yml +10 -0
  42. data/example/rails6.0.0/config/credentials.yml.enc +1 -0
  43. data/example/rails6.0.0/config/database.yml +25 -0
  44. data/example/rails6.0.0/config/environment.rb +5 -0
  45. data/example/rails6.0.0/config/environments/development.rb +52 -0
  46. data/example/rails6.0.0/config/environments/production.rb +105 -0
  47. data/example/rails6.0.0/config/environments/test.rb +49 -0
  48. data/example/rails6.0.0/config/initializers/application_controller_renderer.rb +8 -0
  49. data/example/rails6.0.0/config/initializers/backtrace_silencers.rb +7 -0
  50. data/example/rails6.0.0/config/initializers/cors.rb +16 -0
  51. data/example/rails6.0.0/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/example/rails6.0.0/config/initializers/inflections.rb +16 -0
  53. data/example/rails6.0.0/config/initializers/mime_types.rb +4 -0
  54. data/example/rails6.0.0/config/initializers/wrap_parameters.rb +14 -0
  55. data/example/rails6.0.0/config/locales/en.yml +33 -0
  56. data/example/rails6.0.0/config/puma.rb +38 -0
  57. data/example/rails6.0.0/config/routes.rb +5 -0
  58. data/example/rails6.0.0/config/spring.rb +6 -0
  59. data/example/rails6.0.0/config/storage.yml +34 -0
  60. data/example/rails6.0.0/config.ru +5 -0
  61. data/example/rails6.0.0/db/migrate/20211031165333_create_people.rb +11 -0
  62. data/example/rails6.0.0/db/migrate/20211031165612_create_books.rb +11 -0
  63. data/example/rails6.0.0/db/schema.rb +31 -0
  64. data/example/rails6.0.0/db/seeds.rb +7 -0
  65. data/example/rails6.0.0/lib/tasks/.keep +0 -0
  66. data/example/rails6.0.0/log/.keep +0 -0
  67. data/example/rails6.0.0/public/robots.txt +1 -0
  68. data/example/rails6.0.0/storage/.keep +0 -0
  69. data/example/rails6.0.0/test/channels/application_cable/connection_test.rb +11 -0
  70. data/example/rails6.0.0/test/controllers/.keep +0 -0
  71. data/example/rails6.0.0/test/controllers/books_controller_test.rb +38 -0
  72. data/example/rails6.0.0/test/controllers/people_controller_test.rb +38 -0
  73. data/example/rails6.0.0/test/fixtures/.keep +0 -0
  74. data/example/rails6.0.0/test/fixtures/books.yml +11 -0
  75. data/example/rails6.0.0/test/fixtures/files/.keep +0 -0
  76. data/example/rails6.0.0/test/fixtures/people.yml +11 -0
  77. data/example/rails6.0.0/test/integration/.keep +0 -0
  78. data/example/rails6.0.0/test/test_helper.rb +13 -0
  79. data/example/rails6.0.0/tmp/.keep +0 -0
  80. data/example/rails6.0.0/tmp/pids/.keep +0 -0
  81. data/lib/yamls/helpers/config.rb +6 -0
  82. data/lib/yamls/helpers/yaml_load.rb +19 -0
  83. data/lib/yamls/parameters.rb +6 -6
  84. data/lib/{support → yamls/support}/parameters.rb +1 -1
  85. data/lib/yamls/support.rb +8 -0
  86. data/lib/yamls/version.rb +1 -1
  87. data/lib/yamls.rb +3 -2
  88. metadata +74 -8
  89. data/lib/yamls/config.rb +0 -4
  90. data/lib/yamls/yaml_load.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82775f5c26eb978b61f1ebdb112f662c31362ca8d2c7b6cb8f36cd0969b65e96
4
- data.tar.gz: 846d19e0e4ae7a8b90604cc7cbe9d7ab568800b0dcd7af6782f78d8d2f5a0ce9
3
+ metadata.gz: 332114e46336763e257777b1711843bf377a9b60ce6a3bf67849ab3becd09c49
4
+ data.tar.gz: c5f9b03ddeb224f8df226405c78ed2412d7039b12c06da6cec51d3655d768a88
5
5
  SHA512:
6
- metadata.gz: bcb2781002fb52b97f21ee05ad1aa0066f119c33f05329258920e42d2bd5ee4b56b021ac88c2a2669bc663f6fddaa6db1117b11c118443ef195d759024067192
7
- data.tar.gz: 1525fe499ff1eb9ee0124e358e4b6e5c0c9cc12e4c93633451ac22e49d10204a22f5841a2dcea8c4e5140ede4b916bc5ab282943e99ebe95b874376b0f9ad3d3
6
+ metadata.gz: 5215b874ba933c2bbd9480d67d5300e06e31ec93d23299a3786d8c7a0b3855af1c6962e7ed395500f75c2b62c7617d737e87d04549cabc76f0895fcc9db72dd2
7
+ data.tar.gz: 1cabfeb2b743b2e7fdd942c2346c09a2950acd8b8b567f11a99943e55ecbd19ecdddcb295c68ad29bb45af75504fbe0b72b2634a5f03d1e48137dc10a0f102a0
data/.circleci/config.yml CHANGED
@@ -48,6 +48,27 @@ jobs:
48
48
  name: Run test
49
49
  command: cd example/rails5 && bundle exec rake test
50
50
 
51
+ test_rails6_0_0:
52
+ docker:
53
+ - image: cimg/ruby:3.0.2-node
54
+ executor: ruby/default
55
+ steps:
56
+ - checkout
57
+ - run:
58
+ name: Install dependencies
59
+ command: sudo apt-get update -y && sudo apt-get install -y libsqlite3-dev
60
+ - run:
61
+ name: Which bundler?
62
+ command: bundle -v
63
+ - run:
64
+ name: Bundle install
65
+ command: cd example/rails6.0.0 && bundle install --path vendor/bundle
66
+ - run:
67
+ name: Setup db
68
+ command: cd example/rails6.0.0 && bundle exec rails db:migrate
69
+ - run:
70
+ name: Run test
71
+ command: cd example/rails6.0.0 && bundle exec rake test
51
72
 
52
73
  # Invoke jobs via workflows
53
74
  # See: https://circleci.com/docs/2.0/configuration-reference/#workflows
@@ -59,3 +80,6 @@ workflows:
59
80
  - test_rails5:
60
81
  requires:
61
82
  - build
83
+ - test_rails6_0_0:
84
+ requires:
85
+ - build
data/CHANGELOG.md CHANGED
@@ -3,3 +3,8 @@
3
3
  ## [0.1.0] - 2021-10-28
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.2.0] - 2021-11-1
8
+
9
+ - Add support function
10
+ - Add that can be include Yamls::Support::Parameters
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Yamls
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/yamls.svg)](https://badge.fury.io/rb/yamls)
3
4
  [![CircleCI](https://circleci.com/gh/TsuMakoto/yamls/tree/main.svg?style=svg)](https://circleci.com/gh/TsuMakoto/yamls/tree/main)
4
5
 
5
6
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yamls`. To experiment with that code, run `bin/console` for an interactive prompt.
6
7
 
7
- TODO: Delete this and the text above, and describe your gem
8
+ A gem that simplifies strong parameters that lengthen the code in Rails.
8
9
 
9
10
  ## Installation
10
11
 
@@ -24,7 +25,216 @@ Or install it yourself as:
24
25
 
25
26
  ## Usage
26
27
 
27
- TODO: Write usage instructions here
28
+ In ActionController:
29
+
30
+ Before:
31
+
32
+ ```ruby
33
+ def person_params
34
+ params
35
+ .require(:person)
36
+ .permit(
37
+ :name,
38
+ :email,
39
+ :first_name,
40
+ :last_name,
41
+ :age,
42
+ :role,
43
+ # ....other
44
+ )
45
+ end
46
+ ```
47
+
48
+ Use gem:
49
+
50
+ ```ruby
51
+ def person_params
52
+ Yamls::Parameters.new(
53
+ params,
54
+ model: :person,
55
+ action: :post
56
+ ).permit
57
+ end
58
+ ```
59
+
60
+ In Yaml file (default: app/parameters/column.yml):
61
+
62
+ ```yml
63
+ person:
64
+ post:
65
+ - name
66
+ - email
67
+ - first_name
68
+ - last_name
69
+ - age
70
+ - role
71
+ # ... other
72
+ ```
73
+
74
+ ### Include support function
75
+
76
+ If action_name and controller_name(with singularize) are the same as yaml configuration, it can be described below.
77
+
78
+ ```ruby
79
+ class BooksController < ApplicationController
80
+ include Yamls::Support::Parameters
81
+
82
+ def action_name_1
83
+ params = yamls
84
+ end
85
+
86
+ def action_name_2
87
+ params = yamls
88
+ end
89
+
90
+ def action_name_3
91
+ params = yamls
92
+ end
93
+ end
94
+ ```
95
+
96
+ In Yaml file:
97
+
98
+ ```yml
99
+ book:
100
+ action_name_1:
101
+ # set columns
102
+ action_name_2:
103
+ # set columns
104
+ action_name_3:
105
+ # set columns
106
+ ```
107
+
108
+ ### Initialize configuration
109
+
110
+ 1) If you want to specify a file:
111
+
112
+ ```ruby
113
+ Yamls::Parameters.new(
114
+ params,
115
+ file_path: "path/to/column.yml"
116
+ )
117
+
118
+ ```
119
+
120
+ 2) Nested parameters:
121
+
122
+ In Yaml file:
123
+
124
+ ```yml
125
+ main:
126
+ nested1:
127
+ nested2:
128
+ nested3:
129
+ - name
130
+ - label
131
+ - values:
132
+ - a_site
133
+ - b_site
134
+ - c_site
135
+ ```
136
+
137
+ Request params:
138
+
139
+ ```json
140
+
141
+ {
142
+ "books": {
143
+ "name": "Books name",
144
+ "label": "Books label",
145
+ "values": {
146
+ "a_site": 1000,
147
+ "b_site": 2000,
148
+ "c_site": 3000
149
+ }
150
+ }
151
+ }
152
+
153
+ ```
154
+
155
+ In controller:
156
+
157
+ ```ruby
158
+ Yamls::Parameters.new(
159
+ params,
160
+ required: :book,
161
+ nested: %i[main nested1 neste2 neste3]
162
+ )
163
+
164
+ ```
165
+
166
+ 3) Model specification only:
167
+
168
+ If the parameters of create and update are the same, you want to combine them into one.
169
+
170
+ ```yml
171
+ book:
172
+ - name
173
+ - label
174
+ - value
175
+
176
+ ```
177
+
178
+ ```ruby
179
+ Yamls::Parameters.new(
180
+ params,
181
+ model: :book,
182
+ )
183
+
184
+ ```
185
+
186
+ 4) If you don't need a require method chain:
187
+
188
+ ```yml
189
+ book:
190
+ - name
191
+ - label
192
+ - value
193
+
194
+ ```
195
+
196
+ Request params:
197
+
198
+ ```json
199
+
200
+ {
201
+ "name": "Books name",
202
+ "label": "Books label",
203
+ "value": 1000
204
+ }
205
+
206
+ ```
207
+
208
+ In controller:
209
+
210
+ ```ruby
211
+ Yamls::Parameters.new(
212
+ params,
213
+ nested: %i[book] # if you have a yaml with multi level
214
+ )
215
+
216
+ ```
217
+
218
+ or
219
+
220
+ ```ruby
221
+ Yamls::Parameters.new(
222
+ params,
223
+ model: :book,
224
+ required: nil
225
+ )
226
+
227
+ ```
228
+
229
+ ```ruby
230
+ Yamls::Parameters.new(
231
+ params,
232
+ action: :book,
233
+ required: nil
234
+ )
235
+
236
+ ```
237
+
28
238
 
29
239
  ## Development
30
240
 
@@ -25,7 +25,7 @@ gem 'puma', '~> 3.11'
25
25
  # Reduces boot times through caching; required in config/boot.rb
26
26
  gem 'bootsnap', '>= 1.1.0', require: false
27
27
 
28
- gem 'yamls'
28
+ gem 'yamls', '~> 0.2.0'
29
29
 
30
30
  # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
31
31
  # gem 'rack-cors'
@@ -1,6 +1,8 @@
1
1
  class BooksController < ApplicationController
2
2
  before_action :set_book, only: [:show, :update, :destroy]
3
3
 
4
+ include Yamls::Support::Parameters
5
+
4
6
  # GET /books
5
7
  def index
6
8
  @books = Book.all
@@ -46,10 +48,6 @@ class BooksController < ApplicationController
46
48
 
47
49
  # Only allow a trusted parameter "white list" through.
48
50
  def book_params
49
- Yamls::Parameters.new(
50
- params,
51
- model: :book,
52
- action: action_name,
53
- ).permit
51
+ params.require(:book).permit(:name, :label, :value)
54
52
  end
55
53
  end
@@ -48,7 +48,7 @@ class PeopleController < ApplicationController
48
48
  def person_params
49
49
  Yamls::Parameters.new(
50
50
  params,
51
- model: :people,
51
+ model: :person,
52
52
  action: :post
53
53
  ).permit
54
54
  end
@@ -2,8 +2,8 @@ class CreatePeople < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table :people do |t|
4
4
  t.string :name
5
- t.string :age
6
- t.string :role
5
+ t.integer :age
6
+ t.integer :role
7
7
 
8
8
  t.timestamps
9
9
  end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2021_10_31_052741) do
13
+ ActiveRecord::Schema.define(version: 2021_10_31_170917) do
14
14
 
15
15
  create_table "books", force: :cascade do |t|
16
16
  t.string "name"
@@ -22,8 +22,8 @@ ActiveRecord::Schema.define(version: 2021_10_31_052741) do
22
22
 
23
23
  create_table "people", force: :cascade do |t|
24
24
  t.string "name"
25
- t.string "age"
26
- t.string "role"
25
+ t.integer "age"
26
+ t.integer "role"
27
27
  t.datetime "created_at", null: false
28
28
  t.datetime "updated_at", null: false
29
29
  end
@@ -12,13 +12,7 @@ class BooksControllerTest < ActionDispatch::IntegrationTest
12
12
 
13
13
  test "should create book" do
14
14
  assert_difference('Book.count') do
15
- post books_url, params: {
16
- book: {
17
- name: "test-book",
18
- label: "test-label",
19
- value: 1500
20
- }
21
- }, as: :json
15
+ post books_url, params: { book: { label: @book.label, name: @book.name, value: @book.value } }, as: :json
22
16
  end
23
17
 
24
18
  assert_response 201
@@ -30,13 +24,7 @@ class BooksControllerTest < ActionDispatch::IntegrationTest
30
24
  end
31
25
 
32
26
  test "should update book" do
33
- patch book_url(@book), params: {
34
- book: {
35
- name: "test-book",
36
- label: "test-label",
37
- value: 1500
38
- }
39
- }, as: :json
27
+ patch book_url(@book), params: { book: { label: @book.label, name: @book.name, value: @book.value } }, as: :json
40
28
  assert_response 200
41
29
  end
42
30
 
@@ -12,13 +12,7 @@ class PeopleControllerTest < ActionDispatch::IntegrationTest
12
12
 
13
13
  test "should create person" do
14
14
  assert_difference('Person.count') do
15
- post people_url, params: {
16
- people: {
17
- name: "test01",
18
- age: 10,
19
- role: 0
20
- }
21
- }, as: :json
15
+ post people_url, params: { person: { age: @person.age, name: @person.name, role: @person.role } }, as: :json
22
16
  end
23
17
 
24
18
  assert_response 201
@@ -30,13 +24,7 @@ class PeopleControllerTest < ActionDispatch::IntegrationTest
30
24
  end
31
25
 
32
26
  test "should update person" do
33
- patch person_url(@person), params: {
34
- people: {
35
- name: "test01",
36
- age: 10,
37
- role: 0
38
- }
39
- }, as: :json
27
+ patch person_url(@person), params: { person: { age: @person.age, name: @person.name, role: @person.role } }, as: :json
40
28
  assert_response 200
41
29
  end
42
30
 
@@ -1,10 +1,11 @@
1
1
  # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
2
 
3
- # This model initially had no columns defined. If you add columns to the
4
- # model remove the '{}' from the fixture names and add the columns immediately
5
- # below each fixture, per the syntax in the comments below
6
- #
7
3
  one:
8
- name: book1
9
- label: test-laebl
10
- value: 1000
4
+ name: MyString
5
+ label: MyString
6
+ value: 1
7
+
8
+ two:
9
+ name: MyString
10
+ label: MyString
11
+ value: 1
@@ -1,10 +1,11 @@
1
1
  # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
2
 
3
- # This model initially had no columns defined. If you add columns to the
4
- # model remove the '{}' from the fixture names and add the columns immediately
5
- # below each fixture, per the syntax in the comments below
6
- #
7
3
  one:
8
- name: test
9
- age: 0
10
- role: 0
4
+ name: MyString
5
+ age: 1
6
+ role: 1
7
+
8
+ two:
9
+ name: MyString
10
+ age: 1
11
+ role: 1
@@ -0,0 +1,33 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+ /db/*.sqlite3-*
14
+
15
+ # Ignore all logfiles and tempfiles.
16
+ /log/*
17
+ /tmp/*
18
+ !/log/.keep
19
+ !/tmp/.keep
20
+
21
+ # Ignore pidfiles, but keep the directory.
22
+ /tmp/pids/*
23
+ !/tmp/pids/
24
+ !/tmp/pids/.keep
25
+
26
+ # Ignore uploaded files in development.
27
+ /storage/*
28
+ !/storage/.keep
29
+ .byebug_history
30
+
31
+ # Ignore master key for decrypting credentials and more.
32
+ /config/master.key
33
+ /vendor/
@@ -0,0 +1 @@
1
+ 3.0.2
@@ -0,0 +1,43 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby '3.0.2'
5
+
6
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
7
+ gem 'rails', '~> 6.0.4', '>= 6.0.4.1'
8
+ # Use sqlite3 as the database for Active Record
9
+ gem 'sqlite3', '~> 1.4'
10
+ # Use Puma as the app server
11
+ gem 'puma', '~> 4.1'
12
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13
+ # gem 'jbuilder', '~> 2.7'
14
+ # Use Redis adapter to run Action Cable in production
15
+ # gem 'redis', '~> 4.0'
16
+ # Use Active Model has_secure_password
17
+ # gem 'bcrypt', '~> 3.1.7'
18
+
19
+ # Use Active Storage variant
20
+ # gem 'image_processing', '~> 1.2'
21
+
22
+ # Reduces boot times through caching; required in config/boot.rb
23
+ gem 'bootsnap', '>= 1.4.2', require: false
24
+
25
+ gem 'yamls', '~> 0.2.0'
26
+
27
+ # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
28
+ # gem 'rack-cors'
29
+
30
+ group :development, :test do
31
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
32
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
33
+ end
34
+
35
+ group :development do
36
+ gem 'listen', '~> 3.2'
37
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
38
+ gem 'spring'
39
+ gem 'spring-watcher-listen', '~> 2.0.0'
40
+ end
41
+
42
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
43
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
File without changes
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::API
2
+ end
@@ -0,0 +1,53 @@
1
+ class BooksController < ApplicationController
2
+ before_action :set_book, only: [:show, :update, :destroy]
3
+
4
+ include Yamls::Support::Parameters
5
+
6
+ # GET /books
7
+ def index
8
+ @books = Book.all
9
+
10
+ render json: @books
11
+ end
12
+
13
+ # GET /books/1
14
+ def show
15
+ render json: @book
16
+ end
17
+
18
+ # POST /books
19
+ def create
20
+ @book = Book.new(book_params)
21
+
22
+ if @book.save
23
+ render json: @book, status: :created, location: @book
24
+ else
25
+ render json: @book.errors, status: :unprocessable_entity
26
+ end
27
+ end
28
+
29
+ # PATCH/PUT /books/1
30
+ def update
31
+ if @book.update(book_params)
32
+ render json: @book
33
+ else
34
+ render json: @book.errors, status: :unprocessable_entity
35
+ end
36
+ end
37
+
38
+ # DELETE /books/1
39
+ def destroy
40
+ @book.destroy
41
+ end
42
+
43
+ private
44
+ # Use callbacks to share common setup or constraints between actions.
45
+ def set_book
46
+ @book = Book.find(params[:id])
47
+ end
48
+
49
+ # Only allow a trusted parameter "white list" through.
50
+ def book_params
51
+ yamls
52
+ end
53
+ end
@@ -0,0 +1,55 @@
1
+ class PeopleController < ApplicationController
2
+ before_action :set_person, only: [:show, :update, :destroy]
3
+
4
+ # GET /people
5
+ def index
6
+ @people = Person.all
7
+
8
+ render json: @people
9
+ end
10
+
11
+ # GET /people/1
12
+ def show
13
+ render json: @person
14
+ end
15
+
16
+ # POST /people
17
+ def create
18
+ @person = Person.new(person_params)
19
+
20
+ if @person.save
21
+ render json: @person, status: :created, location: @person
22
+ else
23
+ render json: @person.errors, status: :unprocessable_entity
24
+ end
25
+ end
26
+
27
+ # PATCH/PUT /people/1
28
+ def update
29
+ if @person.update(person_params)
30
+ render json: @person
31
+ else
32
+ render json: @person.errors, status: :unprocessable_entity
33
+ end
34
+ end
35
+
36
+ # DELETE /people/1
37
+ def destroy
38
+ @person.destroy
39
+ end
40
+
41
+ private
42
+ # Use callbacks to share common setup or constraints between actions.
43
+ def set_person
44
+ @person = Person.find(params[:id])
45
+ end
46
+
47
+ # Only allow a trusted parameter "white list" through.
48
+ def person_params
49
+ Yamls::Parameters.new(
50
+ params,
51
+ model: :person,
52
+ action: :post
53
+ ).permit
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end