Created
January 31, 2012 15:57
-
-
Save achiurizo/1711289 to your computer and use it in GitHub Desktop.
example decorator with padrino
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
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