Module: Kadmin::Presentable

Extended by:
ActiveSupport::Concern
Included in:
Finder, Navbar::Link, Navbar::Section, Pager
Defined in:
lib/kadmin/presentable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#present(view = nil) ⇒ Object

Delegates present to a newly instantiated presenter object Checks the including class' presenter_class attribute, with fallback to an inner Presenter class

Parameters:

  • view (ActiveView::Base) (defaults to: nil)

    the view to present in if available; can be supplied to the presenter later

Raises:

  • (Kadmin::Error)

    raises an error if no presenter class defined



24
25
26
27
28
29
30
# File 'lib/kadmin/presentable.rb', line 24

def present(view = nil)
  if self.class.presenter_class.nil?
    raise Kadmin::Error, 'cannot present without a presenter_class'
  else
    return self.class.presenter_class.new(self, view: view)
  end
end