class Presents::AggregatePresenter

Public Class Methods

new(presenters, template) click to toggle source

Internal: Create a new presenter.

Called by present method in ApplicationHelper.

presenters - A hash of the access method name and the presenter

Returns self.

# File lib/presents/aggregate_presenter.rb, line 11
def initialize(presenters, template)
  @presenters = presenters
  @template = template

  @presenters.each do |presenter|
    class_eval do
      define_method(presenter.class.name.underscore.to_sym) do
        presenter
      end
    end
  end
  self
end

Public Instance Methods

h() click to toggle source

Public: Access the view for helper methods.

Examples

class XxxPresenter < AggregatePresenter
  ...
  def my_attribute
    h.content_tag :span, "Duck", :class => "mallard"
  end
  ...
end

Returns the template.

# File lib/presents/aggregate_presenter.rb, line 38
def h
  @template
end
method_missing(*args, &block) click to toggle source

Internal: Send any unknown methods to the template.

This is done so you don’t have to access them through h.

Examples

class XxxPresenter < AggregatePresenter
  ...
  def my_attribute
    content_tag :span, "Duck", :class => "mallard"
  end
  ...
end
# File lib/presents/aggregate_presenter.rb, line 56
def method_missing(*args, &block)
  @template.send(*args, &block)
end