Class: BasePresenter

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

Overview

Class every presenter class should inherit from

Author:

  • Lovell McIlwain

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



6
7
8
9
# File 'lib/myrails/templates/presenters/base.rb', line 6

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



30
31
32
# File 'lib/myrails/templates/presenters/base.rb', line 30

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

Instance Method Details

#format_date(date) ⇒ Object

Same as application helper short date



12
13
14
# File 'lib/myrails/templates/presenters/base.rb', line 12

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