Created
April 29, 2014 21:09
-
-
Save bogn/cfbd3e4528cf3dcd7f94 to your computer and use it in GitHub Desktop.
versioned API through inheritance
This file contains hidden or 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
module Export | |
module V1 | |
class GroupSerializer < ActiveModel::Serializers | |
attributes :items | |
def items | |
docs = object.items.order_by(:position.asc) | |
ItemsSerializer.new(docs, special_options).serializable_hash | |
end | |
end | |
end | |
end |
This file contains hidden or 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
module Export | |
module V1 | |
class ItemsSerializer < ActiveModel::Serializer | |
# ... | |
end | |
end | |
end |
This file contains hidden or 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
module Export | |
module V2 | |
class GroupSerializer < ::Export::V1::GroupSerializer | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Export::V2::GroupSerializer#items
works withExport::V1::ItemsSerializer
in line 9 while I want it to work with the one from it's own namespace (Export::V2::ItemsSerializer
) even though it uses theitems
method from V1. Is that even possible?