Class: Prospecto::PresenterView

Inherits:
Object
  • Object
show all
Defined in:
lib/prospecto/presenter_view.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PresenterView

Returns a new instance of PresenterView.



3
4
5
6
7
8
9
10
11
12
# File 'lib/prospecto/presenter_view.rb', line 3

def initialize(args={})
  args.each do |name, value|
    if respond_to? name
      instance_variable_set("@#{name}", value)
    else
      # Stop everything there is a design problem.
      raise ArgumentError.new("Unknown property '#{name}' for class '#{self.class.name}'.")
    end
  end
end

Class Method Details

.accepts(*args) ⇒ Object

Accepts means the view uses the member internally, but it is not available outside the class.



20
21
22
23
24
25
26
27
# File 'lib/prospecto/presenter_view.rb', line 20

def accepts(*args)
  args.each do |name|
    define_method name do
      instance_variable_get("@#{name}")
    end
    protected name
  end
end