Skip to content

Commit

Permalink
Add 'code' attribute and its getter/setter to season model
Browse files Browse the repository at this point in the history
This commit introduces a new 'code' attribute to the season model, derived from the season number. Modifications include updating the schema and test cases to accommodate the new attribute. These changes ensure that each season has a unique code based on its number.
  • Loading branch information
afuno committed Sep 22, 2024
1 parent 7a3c7de commit 368001e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/usual/example1/season.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ class Season < Datory::Base
# uuid! :serialId, to: :serial_id

integer! :number
string! :code

# many! :episodes, include: Episode

date! :premieredOn, to: :premiered_on
date? :endedOn, to: :ended_on

getter :code do |attributes:|
"s#{attributes.fetch(:number)}"
end

setter :code do |attributes:|
"s#{attributes.fetch(:number)}"
end
end
end
end
4 changes: 4 additions & 0 deletions spec/examples/usual/example1/serial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
{
id: "27df8a44-556f-4e08-9984-4aa663b78f98",
number: 1,
code: "s1",
premieredOn: "2008-09-03",
endedOn: "2008-11-26"
}
Expand Down Expand Up @@ -354,6 +355,7 @@
{
id: "27df8a44-556f-4e08-9984-4aa663b78f98",
number: 1,
code: "s1",
premieredOn: "2008-09-03",
endedOn: "2008-11-26"
}
Expand Down Expand Up @@ -1203,6 +1205,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| id | String | id | String |
| number | Integer | number | Integer |
| code | String | code | String |
| premieredOn | String | premiered_on | Date |
| endedOn | [String, NilClass] | ended_on | [Date, NilClass] |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1319,6 +1322,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| id | String | id | String |
| number | Integer | number | Integer |
| code | String | code | String |
| premieredOn | String | premiered_on | Date |
| endedOn | [String, NilClass] | ended_on | [Date, NilClass] |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 368001e

Please sign in to comment.