Class: Decidim::NilPresenter

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/app/presenters/decidim/nil_presenter.rb

Overview

A default presenter for the cases when the presented object is nil. For example, when there are data inconsistencies like when a Meeting which is the creator of a proposal is removed. This presenter will also be useful if the presenter for the presented object cannot be resolved.

It behaves as a presenter for deleted resources. Returns an empty string for most of the method calls.

Instance Method Summary collapse

Constructor Details

#initializeNilPresenter

Returns a new instance of NilPresenter.



11
# File 'decidim-core/app/presenters/decidim/nil_presenter.rb', line 11

def initialize(*); end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *_args) ⇒ Object



25
26
27
28
29
# File 'decidim-core/app/presenters/decidim/nil_presenter.rb', line 25

def method_missing(method, *_args)
  return false if method.end_with?("?")

  ""
end

Instance Method Details

#avatar_url(_variant = nil) ⇒ Object



17
18
19
# File 'decidim-core/app/presenters/decidim/nil_presenter.rb', line 17

def avatar_url(_variant = nil)
  Decidim::AvatarUploader.new(Decidim::User.new, :avatar).default_url
end

#deleted?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'decidim-core/app/presenters/decidim/nil_presenter.rb', line 13

def deleted?
  true
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'decidim-core/app/presenters/decidim/nil_presenter.rb', line 21

def respond_to_missing?(*)
  true
end