Skip to content

Instantly share code, notes, and snippets.

@watzon
Last active June 14, 2019 21:46
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 watzon/2862724aa8ff34f80d9e6e185c9462ac to your computer and use it in GitHub Desktop.
Save watzon/2862724aa8ff34f80d9e6e185c9462ac to your computer and use it in GitHub Desktop.
Testing decorator implementation with Lucky
abstract class DecoratorBase
private macro decorate(ident, name = nil)
@_{{ ident.id.stringify.downcase.id }} : {{ ident.id }}
forward_missing_to @_{{ ident.id.stringify.downcase.id }}
def initialize(@_{{ ident.id.stringify.downcase.id }} : {{ ident.id }})
end
end
end
class UserDecorator < DecoratorBase
decorate User
def profile_photo
if photo = profile_picture_url
photo
else
"https://lejeunefoundation.org/wp-content/uploads/2017/06/male.jpg"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment