Class: PowerTypes::BasePresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/power_types/patterns/presenter/base_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(view, params = {}) ⇒ BasePresenter

Returns a new instance of BasePresenter.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/power_types/patterns/presenter/base_presenter.rb', line 3

def initialize(view, params = {})
  @h = view

  params.each_pair do |attribute, value|
    if respond_to?(attribute, true)
      raise PowerTypes::PresenterError.new(
        "attribute #{attribute} already defined in presenter"
      )
    end

    singleton_class.send(:attr_accessor, attribute)
    instance_variable_set("@#{attribute}", decorated_value(value))
  end
end