class BasePresenter

Class every presenter class should inherit from

Public Class Methods

new(object, template) click to toggle source

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

# File lib/myrails/templates/rails/app/presenters/base.rb, line 4
def initialize(object, template)
  @object = object
  @template = template
end

Private Class Methods

presents(name) click to toggle source

Class method to call the object by its class

# File lib/myrails/templates/rails/app/presenters/base.rb, line 16
def self.presents(name)
  define_method(name) do
    @object
  end
end

Public Instance Methods

format_date(date) click to toggle source

Same as application helper short date

# File lib/myrails/templates/rails/app/presenters/base.rb, line 10
def format_date(date)
  date.strftime("%Y-%m-%d")
end

Private Instance Methods

method_missing(*args, &block) click to toggle source

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

# File lib/myrails/templates/rails/app/presenters/base.rb, line 28
def method_missing(*args, &block)
  @template.send(*args, &block)
end
t() click to toggle source

Accessor for template methods

# File lib/myrails/templates/rails/app/presenters/base.rb, line 23
def t
  @template
end