Last active
July 11, 2017 08:21
-
-
Save Groogy/13d282820360b4f6dbe5bb8c04e5cd42 to your computer and use it in GitHub Desktop.
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
class FooBar | |
def initialize(@value = 0) | |
end | |
def value | |
@value | |
end | |
protected def value=(val) | |
@value = val | |
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
abstract class Serializer(Type) | |
def initialize(@output) | |
end | |
def write(obj : Type) | |
# Add meta data here? | |
write_data(obj) | |
end | |
abstract def write_data(obj : Type) | |
end | |
class FooBar | |
class Serializer < Serializer(FooBar) | |
def write_data(obj : FooBar) | |
@output[:value] = obj.value | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment