Skip to content

Instantly share code, notes, and snippets.

@mrkplt
Last active August 29, 2015 14:11
Show Gist options
  • Save mrkplt/cbc4c01038be533a43df to your computer and use it in GitHub Desktop.
Save mrkplt/cbc4c01038be533a43df to your computer and use it in GitHub Desktop.

Revisions

  1. mrkplt renamed this gist Jan 5, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. mrkplt created this gist Dec 9, 2014.
    23 changes: 23 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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