Class: Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/pres/presenter.rb

Overview

Base Presenter class Construct with object, view_context, and optional options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, view_context = nil, options = {}) ⇒ Presenter

Returns a new instance of Presenter.



8
9
10
11
12
# File 'lib/pres/presenter.rb', line 8

def initialize(object, view_context = nil, options = {})
  self.object = object
  self.view_context = view_context
  self.options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Send missing symbols to view_context



15
16
17
# File 'lib/pres/presenter.rb', line 15

def method_missing(symbol, *args, &block)
  view_context.send(symbol, *args, &block)
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



4
5
6
# File 'lib/pres/presenter.rb', line 4

def object
  @object
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/pres/presenter.rb', line 4

def options
  @options
end

#view_contextObject

Returns the value of attribute view_context.



4
5
6
# File 'lib/pres/presenter.rb', line 4

def view_context
  @view_context
end

Instance Method Details

#respond_to?(symbol, _ = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pres/presenter.rb', line 19

def respond_to?(symbol, _ = false)
  super || view_context.respond_to?(symbol, true)
end