Skip to content

Instantly share code, notes, and snippets.

@xuncheng
Created May 5, 2014 15:39
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 xuncheng/11540130 to your computer and use it in GitHub Desktop.
Save xuncheng/11540130 to your computer and use it in GitHub Desktop.
class BasePresenter
attr_reader :object, :template
def initialize(object, template)
@object = object
@template = template
end
def self.presents(name)
define_method(name) { object }
end
private
def method_missing(method_name, *args, &block)
template.send(method_name, *args, &block)
end
def respond_to_missing?(method_name, include_private = false)
template.respond_to?(method_name, include_private) || super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment