-
-
Save EdgarOrtegaRamirez/1e57a4ecc1ca27a1ced6 to your computer and use it in GitHub Desktop.
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
# Hides Draper decorator inside the model and lazily decorates resources | |
# | |
# https://gist.github.com/firedev/7a82059b30a2157d4c56 | |
# | |
# model.rb: | |
# include Decorated | |
# | |
# Just make sure there are no overlapping method names in ModelDecorator | |
module Decorated | |
extend ActiveSupport::Concern | |
def method_missing(method, *args) | |
return decorated_resource.send(method, *args) if decorated_resource.respond_to?(method) | |
super | |
end | |
def decorated_resource | |
@decorated_resource ||= decorate | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment