Module: DelegatedPresenter::PresentsBeforeRendering::ClassMethods

Defined in:
lib/delegated_presenter/presents_before_rendering.rb

Instance Method Summary collapse

Instance Method Details

#presents(instance_var1, instance_var2, [...]) ⇒ Object #presents(instance_var1, instance_var2, [...], options) ⇒ Object Also known as: present

Sets up a presenter for instance variables. By default it will try to determine the presenter but this can be overridden via the “with” option.

Overloads:

  • #presents(instance_var1, instance_var2, [...]) ⇒ Object

    Specifies which instance variables to present, assumes the presenter has a name of InstanceClassPresenter.

    Parameters:

    • instance_vars

      the instance variables to present.

  • #presents(instance_var1, instance_var2, [...], options) ⇒ Object

    Specifies which instance variables to present, assumes the presenter has a name of InstanceClassPresenter.

    Parameters:

    • instance_vars

      the instance variables to present.

    Options Hash (options):

    • :with (Symbol)

      The presenter to use.

    • :only (Symbol)

      the only action to present on.

    • :except (Symbol)

      these actions to present on.



56
57
58
59
60
61
# File 'lib/delegated_presenter/presents_before_rendering.rb', line 56

def presents(*instance_vars)
  options                        = instance_vars.extract_options!
  instance_vars.each do |var|
    self.presents_before_rendering[var.to_sym] = options
  end
end

#presents_before_renderingObject



34
35
36
# File 'lib/delegated_presenter/presents_before_rendering.rb', line 34

def presents_before_rendering
  @presents_before_rendering ||= {} unless name == 'ActionController::Base'
end