Skip to content

Instantly share code, notes, and snippets.

@achiurizo
Created January 31, 2012 15:57
Show Gist options
  • Save achiurizo/1711289 to your computer and use it in GitHub Desktop.
Save achiurizo/1711289 to your computer and use it in GitHub Desktop.
example decorator with padrino
module Decorator
include Padrino::Helpers::OutputHelpers
include Padrino::Helpers::TagHelpers
include Padrino::Helpers::FormatHelpers
include Padrino::Helpers::AssetTagHelpers
def self.included(base)
base.class_eval { attr_accessor :model }
base.extend ClassMethods
end
def initialize(model)
@model = model
end
module ClassMethods
def method_missing(meth, *args)
@model.class.respond_to?(meth) ? @model.class.send(meth, *args) : super
end
def respond_to?(meth)
@model.class.respond_to?(meth) || super
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment