Skip to content

Instantly share code, notes, and snippets.

@Groogy
Last active July 11, 2017 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Groogy/13d282820360b4f6dbe5bb8c04e5cd42 to your computer and use it in GitHub Desktop.
Save Groogy/13d282820360b4f6dbe5bb8c04e5cd42 to your computer and use it in GitHub Desktop.
class FooBar
def initialize(@value = 0)
end
def value
@value
end
protected def value=(val)
@value = val
end
end
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