Class: Presenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(subject, options = {}) ⇒ Presenter

Returns a new instance of Presenter.



2
3
4
5
# File 'app/presenters/presenter.rb', line 2

def initialize(subject, options = {})
  @subject = subject
  set_default_options(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)



39
40
41
42
43
44
45
# File 'app/presenters/presenter.rb', line 39

def method_missing(*args, &block)
  if args.is_a?(Array) && @options.has_key?(args.first)
    @options[args.first] 
  else
    @subject.send(*args, &block)
  end
end

Instance Method Details

#set_option(option, value) ⇒ Object



15
16
17
# File 'app/presenters/presenter.rb', line 15

def set_option(option, value)
  @options[option] = value
end

#set_options(options) ⇒ Object

Raises:

  • (NotImplementedError)


11
12
13
# File 'app/presenters/presenter.rb', line 11

def set_options(options)
  raise NotImplementedError
end