class Cynic::Controller

Attributes

before_actions[RW]
request[RW]

Public Class Methods

add_before_action(method, action=:all) click to toggle source
# File lib/cynic/controller.rb, line 19
def add_before_action(method, action=:all)
  before_actions[action] <<= method
end
before_action(method, options={}) click to toggle source
# File lib/cynic/controller.rb, line 11
def before_action(method, options={})
  if options.has_key? :only
    [options[:only]].flatten.each { |action|  add_before_action(method, action) }
  else
    add_before_action(method)
  end
end

Public Instance Methods

params() click to toggle source
# File lib/cynic/controller.rb, line 35
def params
  request.params.each do |k,v|
    request.update_param(k.to_sym, v) if k.is_a? String
  end
  
  request.params
end
render(action) click to toggle source
# File lib/cynic/controller.rb, line 24
def render(action)
  @action = action
  Renderer.new(full_path, self).body
end
response(method) click to toggle source
# File lib/cynic/controller.rb, line 29
def response(method)
  eval_set_of_actions
  eval_set_of_actions(method)
  send method
end

Private Instance Methods

eval_set_of_actions(set=:all) click to toggle source
# File lib/cynic/controller.rb, line 60
def eval_set_of_actions(set=:all)
  self.class.before_actions[set].each {|action| eval(action.to_s)}
end
full_path() click to toggle source

The path plus the current action.html.erb

# File lib/cynic/controller.rb, line 51
def full_path
  path + "/#{@action}.html.erb"
end
name() click to toggle source

The Controllers class name without the word ‘controller` in it.

# File lib/cynic/controller.rb, line 56
def name
  self.class.to_s.gsub(/controller$/i, "")
end
path() click to toggle source

The name split and joined into a string seperated by “/”‘s

# File lib/cynic/controller.rb, line 46
def path
  name.split("::").join("/").downcase
end