-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce alternative approach to inline associations
- Loading branch information
Showing
11 changed files
with
83 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
<%- properties.each do |property| -%> | ||
<%= property.to_s.strip.gsub(/^/, ' ') %>; | ||
<%- end -%> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Typelizer digest 31c711d30b829018bdc69e3e09ca8e72 | ||
// | ||
// DO NOT MODIFY: This file was automatically generated by Typelizer. | ||
|
||
type AlbaInline = { | ||
id: number; | ||
username: string; | ||
active: boolean; | ||
untyped_posts: Array<{ | ||
id: unknown; | ||
title: unknown; | ||
}>; | ||
posts: Array<{ | ||
id: number; | ||
title: string; | ||
}>; | ||
deep_posts: Array<{ | ||
id: number; | ||
title: string | null; | ||
user: { | ||
id: number; | ||
username: string; | ||
}; | ||
}>; | ||
} | ||
|
||
export default AlbaInline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Alba | ||
class InlineSerializer < BaseSerializer | ||
typelize_from ::User | ||
attributes :id, :username, :active | ||
|
||
has_many :untyped_posts do | ||
attributes :id, :title | ||
end | ||
|
||
has_many :posts do | ||
typelize id: :number | ||
|
||
attributes :id, title: [String, true] | ||
end | ||
|
||
has_many :deep_posts do | ||
typelize_from ::Post | ||
attributes :id, :title | ||
|
||
has_one :user do | ||
typelize_from ::User | ||
attributes :id, :username | ||
end | ||
end | ||
end | ||
end |