Class: Cubic::CubicController

Inherits:
Object
  • Object
show all
Extended by:
Logable
Defined in:
lib/cubic/application/controller.rb

Overview

All classes generated by Cubic inherit from CubicController

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Logable

log

Class Attribute Details

.namespace(name, &b) ⇒ Object

Allows for namespacing within controllers who inherit from CubicController



11
12
13
# File 'lib/cubic/application/controller.rb', line 11

def namespace
  @namespace
end

Class Method Details

.delete(url, &block) ⇒ Object



34
35
36
37
# File 'lib/cubic/application/controller.rb', line 34

def delete(url, &block)
  namespace_url(url) if @namespace
  route_setter('DELETE', url, block)
end

.get(url, &block) ⇒ Object



18
19
20
21
22
# File 'lib/cubic/application/controller.rb', line 18

def get(url, &block)
  namespace_url(url) if @namespace
  url[0] == '/' ? url : url.prepend('/')
  route_setter('GET', url, block)
end

.namespace_url(url) ⇒ Object



43
44
45
# File 'lib/cubic/application/controller.rb', line 43

def namespace_url(url)
  url.prepend(@namespace + '/')
end

.post(url, &block) ⇒ Object



24
25
26
27
# File 'lib/cubic/application/controller.rb', line 24

def post(url, &block)
  namespace_url(url) if @namespace
  route_setter('POST', url, block)
end

.put(url, &block) ⇒ Object



29
30
31
32
# File 'lib/cubic/application/controller.rb', line 29

def put(url, &block)
  namespace_url(url) if @namespace
  route_setter('PUT', url, block)
end

.route_setter(request_method, url, block) ⇒ Object



39
40
41
# File 'lib/cubic/application/controller.rb', line 39

def route_setter(request_method, url, block)
  Router.set_route(request_method, url, block)
end