Sha256: c0b7af896f673bac3dba631385a2b0c367400e292dcd020568afa6484aae867c

Contents?: true

Size: 567 Bytes

Versions: 15

Compression:

Stored size: 567 Bytes

Contents

# frozen_string_literal: true

module RailsMiniProfiler
  class BasePresenter < SimpleDelegator
    def initialize(model, view, **_kwargs)
      @h = view
      super(model)
    end

    attr_reader :h

    alias model __getobj__

    # To avoid having to address the view context explicitly we try to delegate to it
    def method_missing(method, *args, &block)
      h.public_send(method, *args, &block)
    rescue NoMethodError
      super
    end

    def respond_to_missing?(method_name, *args)
      h.respond_to?(method_name, *args) || super
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rails_mini_profiler-0.7.3 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.7.2 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.7.1 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.7.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.6.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.5.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.4.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.3.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.2.1 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.2.0 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.1.3 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.1.2 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.1.1 app/presenters/rails_mini_profiler/base_presenter.rb
rails_mini_profiler-0.1.0 app/presenters/rails_mini_profiler/base_presenter.rb