Class: BasePresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/myrails/templates/rails/app/presenters/base.rb

Overview

Class every presenter class should inherit from

Instance Method Summary collapse

Constructor Details

#initialize(object, template) ⇒ BasePresenter

Initialize class with object to be presented and the view it is to be presented on



4
5
6
7
# File 'lib/myrails/templates/rails/app/presenters/base.rb', line 4

def initialize(object, template)
  @object = object
  @template = template
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)

In the event a method called can’t be found, default to the template methods



28
29
30
# File 'lib/myrails/templates/rails/app/presenters/base.rb', line 28

def method_missing(*args, &block)
  @template.send(*args, &block)
end

Instance Method Details

#format_date(date) ⇒ Object

Same as application helper short date



10
11
12
# File 'lib/myrails/templates/rails/app/presenters/base.rb', line 10

def format_date(date)
  date.strftime("%Y-%m-%d")
end