Last active
August 29, 2015 14:11
-
-
Save mrkplt/cbc4c01038be533a43df to your computer and use it in GitHub Desktop.
A quick view model implementation
This file contains hidden or 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
| 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