class AutoViewModel::Base

Public Class Methods

new(local_assigns, view_context:) click to toggle source
Calls superclass method AutoViewModel::Attributes::new
# File lib/auto_view_model/base.rb, line 11
def initialize(local_assigns, view_context:)
  super(local_assigns)
  @view_context = view_context
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source

View models should support helper methods available in the template. By delegating missing methods to view context, we can support all existing Rails and application defined helpers.

Calls superclass method
# File lib/auto_view_model/base.rb, line 20
def method_missing(method, *args, &block)
  if @view_context.respond_to?(method)
    @view_context.public_send(method, *args, &block)
  else
    super
  end
end
respond_to_missing?(method, include_all) click to toggle source
# File lib/auto_view_model/base.rb, line 29
def respond_to_missing?(method, include_all)
  @view_context.respond_to?(method, include_all)
end