Last active
June 14, 2019 21:46
-
-
Save watzon/2862724aa8ff34f80d9e6e185c9462ac to your computer and use it in GitHub Desktop.
Testing decorator implementation with Lucky
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 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 |
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 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