Class: Ramaze::Controller
- Inherits:
-
Object
show all
- Includes:
- Innate::Node, Innate::Traited
- Defined in:
- lib/ramaze/controller.rb
Constant Summary
collapse
- CONTROLLER_LIST =
Set.new
- IRREGULAR_MAPPING =
{
'Controller' => nil,
'MainController' => '/'
}
Class Method Summary
collapse
Class Method Details
75
76
77
|
# File 'lib/ramaze/controller.rb', line 75
def self.app
App[ancestral_trait[:app]]
end
|
.engine(name) ⇒ Object
39
40
41
|
# File 'lib/ramaze/controller.rb', line 39
def self.engine(name)
provide(:html, name.to_sym)
end
|
.generate_mapping(klass_name = self.name) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/ramaze/controller.rb', line 52
def self.generate_mapping(klass_name = self.name)
chunks = klass_name.split(/::/)
return if chunks.empty?
last = chunks.last
return IRREGULAR_MAPPING[last] if IRREGULAR_MAPPING.key?(last)
last.sub!(/Controller$/, '')
'/' << chunks.map{|chunk| chunk.snake_case }.join('/')
end
|
.inherited(into) ⇒ Object
20
21
22
23
24
|
# File 'lib/ramaze/controller.rb', line 20
def self.inherited(into)
Innate::Node.included(into)
CONTROLLER_LIST << into
into.trait :skip_node_map => true
end
|
.map(location, app_name = nil) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/ramaze/controller.rb', line 63
def self.map(location, app_name = nil)
if app_name
trait :app => app_name
else
app_name = ancestral_trait[:app]
end
trait :skip_controller_map => true
App.find_or_create(app_name).map(location, self)
end
|
43
44
45
|
# File 'lib/ramaze/controller.rb', line 43
def self.mapping
Ramaze.to(self)
end
|
79
80
81
82
|
# File 'lib/ramaze/controller.rb', line 79
def self.options
return unless app = self.app
app.options
end
|
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ramaze/controller.rb', line 26
def self.setup
require 'ramaze/controller/default' if CONTROLLER_LIST.empty?
CONTROLLER_LIST.each do |controller|
unless controller.ancestral_trait[:provide_set]
controller.engine(:Etanni)
controller.trait(:provide_set => false)
end
next if controller.trait[:skip_controller_map]
controller.map(generate_mapping(controller.name))
end
end
|
.template(*args) ⇒ Object
84
85
86
87
|
# File 'lib/ramaze/controller.rb', line 84
def self.template(*args)
Ramaze.deprecated('Controller::template', 'Controller::alias_view')
alias_view(*args)
end
|
.view_root(*locations) ⇒ Object
89
90
91
92
|
# File 'lib/ramaze/controller.rb', line 89
def self.view_root(*locations)
Ramaze.deprecated('Controller::view_root', 'Controller::map_views')
map_views(*locations)
end
|