Class: Paradeiser::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/paradeiser/controllers/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ Controller

Returns a new instance of Controller.



5
6
7
8
9
10
# File 'lib/paradeiser/controllers/controller.rb', line 5

def initialize(method)
  @method = method
  @exitstatus = 0
  @has_output = false
  @already_rendered = nil
end

Instance Attribute Details

#exitstatusObject

Returns the value of attribute exitstatus.



3
4
5
# File 'lib/paradeiser/controllers/controller.rb', line 3

def exitstatus
  @exitstatus
end

#has_outputObject

Returns the value of attribute has_output.



3
4
5
# File 'lib/paradeiser/controllers/controller.rb', line 3

def has_output
  @has_output
end

Instance Method Details

#call(args, options) ⇒ Object



12
13
14
15
16
17
# File 'lib/paradeiser/controllers/controller.rb', line 12

def call(args, options)
  @args = args
  @options = options
  send(@method)
  render
end

#get_bindingObject



23
24
25
# File 'lib/paradeiser/controllers/controller.rb', line 23

def get_binding
  return binding
end

#modelObject



19
20
21
# File 'lib/paradeiser/controllers/controller.rb', line 19

def model
  self.class.name.split("::").last.sub('Controller', '')
end

#render(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/paradeiser/controllers/controller.rb', line 27

def render(options = {})
  return if @already_rendered # render only once
  return unless (@options && @options.verbose) || has_output

  if options.has_key?(:text)
    puts options[:text]
  else
    puts View.new(model, @method).render(binding)
  end

  @already_rendered = true
end