Skip to content

Instantly share code, notes, and snippets.

@Samsinite
Created September 26, 2018 06:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Samsinite/504aadce1d88c6d6a411310fdfd5593e to your computer and use it in GitHub Desktop.
Ruby API Annotation DSL
class BazSerializer < BaseSerializer
attribtes :id, :thing, :bar
deprecated_attribute :old_thing
deprecation_flag: ::FeatureFlags::DEPRECATED_FEATURE_FOO,
upgrade_instructions: <<-INSTRUCTIONS
Replace `baz.old_thing` with `baz.thing`
INSTRUCTIONS
deprecated_belongs_to :foo
deprecation_flag: ::FeatureFlags::DEPRECATED_FEATURE_FOO,
upgrade_instructions: <<-INSTRUCTIONS
Replace `baz.foo.bar` with `baz.bar`
INSTRUCTIONS
end
FooSerializer = DeprecatedSerializer.new do
deprecation_flag ::FeatureFlags::DEPRECATED_FEATURE_FOO
upgrade_instructions <<-INSTRUCTIONS
Replace Usage of `foo` with usage of `baz`
INSTRUCTIONS
attributes :id, :bar
has_one :baz
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment