-
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.
feat(model): Introduce poro model plugin
This model plugin would be used in serializers for PORO. It's implementation is empty but it works as expected. See spec/app/app/serializers/alba/poro_serializer.rb for details.
- Loading branch information
1 parent
0b0015a
commit e2d065b
Showing
6 changed files
with
50 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Typelizer | ||
module ModelPlugins | ||
class Poro | ||
# We don't care about intialization | ||
def initialize(...) | ||
end | ||
|
||
def infer_types(prop) | ||
prop | ||
end | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Typelizer digest 3c3acd1390157d9666f0f2be46bfcb1c | ||
// | ||
// DO NOT MODIFY: This file was automatically generated by Typelizer. | ||
|
||
type AlbaPoro = { | ||
foo: unknown; | ||
bar: string | null; | ||
} | ||
|
||
export default AlbaPoro; |
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,9 @@ | ||
class Poro | ||
def foo | ||
"This is foo method" | ||
end | ||
|
||
def as_json | ||
{foo: foo} | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Alba | ||
class PoroSerializer | ||
include Alba::Serializer | ||
include Typelizer::DSL | ||
|
||
typelize_from :poro | ||
|
||
typelizer_config do |c| | ||
# This is required | ||
c.model_plugin = Typelizer::ModelPlugins::Poro | ||
end | ||
|
||
attributes :foo, bar: :String | ||
end | ||
end |