Create a gist now

Instantly share code, notes, and snippets.

Embed
A quick view model implementation
class ViewModel
def initialize(klass)
@klass = klass
end
private
attr_accessor :klass
def method_missing(method_sym, *arguments, &block)
klass.send(method_sym, *arguments, &block)
end
def respond_to?(method_sym)
return true if methods.include?(method_sym)
return true if klass.methods.include?(method_sym)
false
end
def methods
self.class.instance_methods + klass.methods
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment