yamls 0.1.3 → 0.2.2

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 (153) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +49 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +233 -2
  5. data/example/rails-demo/.gitignore +33 -0
  6. data/example/rails-demo/.ruby-version +1 -0
  7. data/example/rails-demo/Gemfile +43 -0
  8. data/example/{rails5 → rails-demo}/README.md +0 -0
  9. data/example/rails-demo/Rakefile +6 -0
  10. data/example/rails-demo/app/channels/application_cable/channel.rb +4 -0
  11. data/example/rails-demo/app/channels/application_cable/connection.rb +4 -0
  12. data/example/rails-demo/app/controllers/application_controller.rb +2 -0
  13. data/example/rails-demo/app/controllers/books_controller.rb +48 -0
  14. data/example/{rails5/test/integration → rails-demo/app/controllers/concerns}/.keep +0 -0
  15. data/example/rails-demo/app/jobs/application_job.rb +7 -0
  16. data/example/rails-demo/app/mailers/application_mailer.rb +4 -0
  17. data/example/rails-demo/app/models/application_record.rb +3 -0
  18. data/example/rails-demo/app/models/book.rb +2 -0
  19. data/example/rails-demo/app/models/concerns/.keep +0 -0
  20. data/example/rails-demo/app/parameters/column.yml +5 -0
  21. data/example/rails-demo/app/views/layouts/mailer.html.erb +13 -0
  22. data/example/rails-demo/app/views/layouts/mailer.text.erb +1 -0
  23. data/example/rails-demo/bin/bundle +114 -0
  24. data/example/rails-demo/bin/rails +9 -0
  25. data/example/rails-demo/bin/rake +9 -0
  26. data/example/rails-demo/bin/setup +33 -0
  27. data/example/rails-demo/bin/spring +17 -0
  28. data/example/rails-demo/config/application.rb +37 -0
  29. data/example/rails-demo/config/boot.rb +4 -0
  30. data/example/rails-demo/config/cable.yml +10 -0
  31. data/example/rails-demo/config/credentials.yml.enc +1 -0
  32. data/example/rails-demo/config/database.yml +25 -0
  33. data/example/rails-demo/config/environment.rb +5 -0
  34. data/example/rails-demo/config/environments/development.rb +52 -0
  35. data/example/rails-demo/config/environments/production.rb +105 -0
  36. data/example/rails-demo/config/environments/test.rb +49 -0
  37. data/example/rails-demo/config/initializers/application_controller_renderer.rb +8 -0
  38. data/example/rails-demo/config/initializers/backtrace_silencers.rb +7 -0
  39. data/example/rails-demo/config/initializers/cors.rb +16 -0
  40. data/example/rails-demo/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/example/rails-demo/config/initializers/inflections.rb +16 -0
  42. data/example/rails-demo/config/initializers/mime_types.rb +4 -0
  43. data/example/rails-demo/config/initializers/wrap_parameters.rb +14 -0
  44. data/example/rails-demo/config/locales/en.yml +33 -0
  45. data/example/rails-demo/config/puma.rb +38 -0
  46. data/example/rails-demo/config/routes.rb +5 -0
  47. data/example/rails-demo/config/spring.rb +6 -0
  48. data/example/rails-demo/config/storage.yml +34 -0
  49. data/example/rails-demo/config.ru +5 -0
  50. data/example/rails-demo/db/migrate/20211101020803_create_books.rb +11 -0
  51. data/example/rails-demo/db/schema.rb +31 -0
  52. data/example/rails-demo/db/seeds.rb +7 -0
  53. data/example/rails-demo/lib/tasks/.keep +0 -0
  54. data/example/rails-demo/log/.keep +0 -0
  55. data/example/rails-demo/public/robots.txt +1 -0
  56. data/example/rails-demo/storage/.keep +0 -0
  57. data/example/rails-demo/test/channels/application_cable/connection_test.rb +11 -0
  58. data/example/rails-demo/test/controllers/.keep +0 -0
  59. data/example/rails-demo/test/controllers/books_controller_test.rb +38 -0
  60. data/example/rails-demo/test/fixtures/.keep +0 -0
  61. data/example/rails-demo/test/fixtures/books.yml +11 -0
  62. data/example/rails-demo/test/fixtures/files/.keep +0 -0
  63. data/example/rails-demo/test/models/.keep +0 -0
  64. data/example/rails-demo/test/models/book_test.rb +7 -0
  65. data/example/rails-demo/test/test_helper.rb +13 -0
  66. data/example/rails-demo/tmp/.keep +0 -0
  67. data/example/rails-demo/tmp/pids/.keep +0 -0
  68. data/example/rails5/Gemfile +1 -1
  69. data/example/rails5/app/controllers/books_controller.rb +3 -5
  70. data/example/rails5/app/controllers/people_controller.rb +1 -1
  71. data/example/rails5/db/migrate/{20211031043641_create_people.rb → 20211031170917_create_people.rb} +2 -2
  72. data/example/rails5/db/schema.rb +3 -3
  73. data/example/rails5/test/controllers/books_controller_test.rb +2 -14
  74. data/example/rails5/test/controllers/people_controller_test.rb +2 -14
  75. data/example/rails5/test/fixtures/books.yml +8 -7
  76. data/example/rails5/test/fixtures/people.yml +8 -7
  77. data/example/rails6.0.0/.gitignore +33 -0
  78. data/example/rails6.0.0/.ruby-version +1 -0
  79. data/example/rails6.0.0/Gemfile +43 -0
  80. data/example/rails6.0.0/README.md +24 -0
  81. data/example/rails6.0.0/Rakefile +6 -0
  82. data/example/rails6.0.0/app/channels/application_cable/channel.rb +4 -0
  83. data/example/rails6.0.0/app/channels/application_cable/connection.rb +4 -0
  84. data/example/rails6.0.0/app/controllers/application_controller.rb +2 -0
  85. data/example/rails6.0.0/app/controllers/books_controller.rb +53 -0
  86. data/example/rails6.0.0/app/controllers/concerns/.keep +0 -0
  87. data/example/rails6.0.0/app/controllers/people_controller.rb +55 -0
  88. data/example/rails6.0.0/app/jobs/application_job.rb +7 -0
  89. data/example/rails6.0.0/app/mailers/application_mailer.rb +4 -0
  90. data/example/rails6.0.0/app/models/application_record.rb +3 -0
  91. data/example/rails6.0.0/app/models/book.rb +2 -0
  92. data/example/rails6.0.0/app/models/concerns/.keep +0 -0
  93. data/example/rails6.0.0/app/models/person.rb +2 -0
  94. data/example/rails6.0.0/app/parameters/column.yml +15 -0
  95. data/example/rails6.0.0/app/views/layouts/mailer.html.erb +13 -0
  96. data/example/rails6.0.0/app/views/layouts/mailer.text.erb +1 -0
  97. data/example/rails6.0.0/bin/bundle +114 -0
  98. data/example/rails6.0.0/bin/rails +9 -0
  99. data/example/rails6.0.0/bin/rake +9 -0
  100. data/example/rails6.0.0/bin/setup +33 -0
  101. data/example/rails6.0.0/bin/spring +17 -0
  102. data/example/rails6.0.0/config/application.rb +37 -0
  103. data/example/rails6.0.0/config/boot.rb +4 -0
  104. data/example/rails6.0.0/config/cable.yml +10 -0
  105. data/example/rails6.0.0/config/credentials.yml.enc +1 -0
  106. data/example/rails6.0.0/config/database.yml +25 -0
  107. data/example/rails6.0.0/config/environment.rb +5 -0
  108. data/example/rails6.0.0/config/environments/development.rb +52 -0
  109. data/example/rails6.0.0/config/environments/production.rb +105 -0
  110. data/example/rails6.0.0/config/environments/test.rb +49 -0
  111. data/example/rails6.0.0/config/initializers/application_controller_renderer.rb +8 -0
  112. data/example/rails6.0.0/config/initializers/backtrace_silencers.rb +7 -0
  113. data/example/rails6.0.0/config/initializers/cors.rb +16 -0
  114. data/example/rails6.0.0/config/initializers/filter_parameter_logging.rb +4 -0
  115. data/example/rails6.0.0/config/initializers/inflections.rb +16 -0
  116. data/example/rails6.0.0/config/initializers/mime_types.rb +4 -0
  117. data/example/rails6.0.0/config/initializers/wrap_parameters.rb +14 -0
  118. data/example/rails6.0.0/config/locales/en.yml +33 -0
  119. data/example/rails6.0.0/config/puma.rb +38 -0
  120. data/example/rails6.0.0/config/routes.rb +5 -0
  121. data/example/rails6.0.0/config/spring.rb +6 -0
  122. data/example/rails6.0.0/config/storage.yml +34 -0
  123. data/example/rails6.0.0/config.ru +5 -0
  124. data/example/rails6.0.0/db/migrate/20211031165333_create_people.rb +11 -0
  125. data/example/rails6.0.0/db/migrate/20211031165612_create_books.rb +11 -0
  126. data/example/rails6.0.0/db/schema.rb +31 -0
  127. data/example/rails6.0.0/db/seeds.rb +7 -0
  128. data/example/rails6.0.0/lib/tasks/.keep +0 -0
  129. data/example/rails6.0.0/log/.keep +0 -0
  130. data/example/rails6.0.0/public/robots.txt +1 -0
  131. data/example/rails6.0.0/storage/.keep +0 -0
  132. data/example/rails6.0.0/test/channels/application_cable/connection_test.rb +11 -0
  133. data/example/rails6.0.0/test/controllers/.keep +0 -0
  134. data/example/rails6.0.0/test/controllers/books_controller_test.rb +38 -0
  135. data/example/rails6.0.0/test/controllers/people_controller_test.rb +38 -0
  136. data/example/rails6.0.0/test/fixtures/.keep +0 -0
  137. data/example/rails6.0.0/test/fixtures/books.yml +11 -0
  138. data/example/rails6.0.0/test/fixtures/files/.keep +0 -0
  139. data/example/rails6.0.0/test/fixtures/people.yml +11 -0
  140. data/example/rails6.0.0/test/integration/.keep +0 -0
  141. data/example/rails6.0.0/test/test_helper.rb +13 -0
  142. data/example/rails6.0.0/tmp/.keep +0 -0
  143. data/example/rails6.0.0/tmp/pids/.keep +0 -0
  144. data/lib/yamls/helpers/config.rb +6 -0
  145. data/lib/yamls/helpers/yaml_load.rb +19 -0
  146. data/lib/yamls/parameters.rb +6 -6
  147. data/lib/yamls/support/parameters.rb +13 -1
  148. data/lib/yamls/support.rb +8 -0
  149. data/lib/yamls/version.rb +1 -1
  150. data/lib/yamls.rb +3 -2
  151. metadata +136 -7
  152. data/lib/yamls/config.rb +0 -4
  153. data/lib/yamls/yaml_load.rb +0 -17
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ class BooksControllerTest < ActionDispatch::IntegrationTest
4
+ setup do
5
+ @book = books(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get books_url, as: :json
10
+ assert_response :success
11
+ end
12
+
13
+ test "should create book" do
14
+ assert_difference('Book.count') do
15
+ post books_url, params: { book: { label: @book.label, name: @book.name, value: @book.value } }, as: :json
16
+ end
17
+
18
+ assert_response 201
19
+ end
20
+
21
+ test "should show book" do
22
+ get book_url(@book), as: :json
23
+ assert_response :success
24
+ end
25
+
26
+ test "should update book" do
27
+ patch book_url(@book), params: { book: { label: @book.label, name: @book.name, value: @book.value } }, as: :json
28
+ assert_response 200
29
+ end
30
+
31
+ test "should destroy book" do
32
+ assert_difference('Book.count', -1) do
33
+ delete book_url(@book), as: :json
34
+ end
35
+
36
+ assert_response 204
37
+ end
38
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ name: MyString
5
+ label: MyString
6
+ value: 1
7
+
8
+ two:
9
+ name: MyString
10
+ label: MyString
11
+ value: 1
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BookTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,13 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require_relative '../config/environment'
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Run tests in parallel with specified workers
7
+ parallelize(workers: :number_of_processors)
8
+
9
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
File without changes
@@ -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]
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -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
File without changes
@@ -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
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Book < ApplicationRecord
2
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ class Person < ApplicationRecord
2
+ end
@@ -0,0 +1,15 @@
1
+ person:
2
+ post:
3
+ - name
4
+ - agen
5
+ - role
6
+
7
+ book:
8
+ create:
9
+ - name
10
+ - label
11
+ - value
12
+ update:
13
+ - name
14
+ - label
15
+ - value
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>