Class: ShortCircuit::Presenter

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

Instance Method Summary collapse

Constructor Details

#initialize(presentable_object) ⇒ Presenter

Returns a new instance of Presenter.



7
8
9
10
# File 'lib/short_circuit/presenter.rb', line 7

def initialize(presentable_object)
  instance_variable_set("@#{presentable_object.class.to_s.downcase}", presentable_object)
  super(presentable_object)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



22
23
24
25
26
27
28
29
30
# File 'lib/short_circuit/presenter.rb', line 22

def method_missing(method, *args, &block)
  if helpers.respond_to?(method)
    helpers.send(method, *args, &block)  
  elsif url_helpers.respond_to?(method)
    url_helpers.send(method, *args, &block)
  else
    super(method, *args, &block)
  end 
end

Instance Method Details

#error_response(error, method, *args, &block) ⇒ Object



16
17
18
# File 'lib/short_circuit/presenter.rb', line 16

def error_response(error, method, *args, &block)
  ''
end

#helpersObject



12
13
14
# File 'lib/short_circuit/presenter.rb', line 12

def helpers
  ApplicationController.helpers
end