Skip to content

Instantly share code, notes, and snippets.

@smedstadc
Created December 11, 2015 19:44
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 smedstadc/67005e648c329c52499f to your computer and use it in GitHub Desktop.
Save smedstadc/67005e648c329c52499f to your computer and use it in GitHub Desktop.
Basic Ruby Decorator
class Decorator
# Uncomment for Rails
#
# include ActionView::Helpers::UrlHelper
attr_reader :decorated
def initialize(decorated)
@decorated = decorated
init_hook
end
private
# Uncomment for Rails
#
# def helpers
# Rails.application.routes.url_helpers
# end
def init_hook
raise "You forgot to implement the init_hook. Hope this helps."
end
def method_missing(m, *args, &block)
@decorated.send(m, *args, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment