Class: AlittleLess
- Inherits:
-
Object
show all
- Includes:
- Router, Util
- Defined in:
- lib/a_little_less.rb,
lib/a_little_less.rb,
lib/a_little_less/env.rb,
lib/a_little_less/rack_app.rb
Defined Under Namespace
Modules: Router, Util
Classes: Env, RackApp
Constant Summary
collapse
- DB_CONF =
"config/db.yml"
- @@controllers =
{}
- @@alias_name_map =
{}
- @@default_controller =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Router
#method, #search_route
Methods included from Util
#add_default_cors_headers, #error_422, #http_options?, #http_origin_allowed?, #not_found, #params, #redir_301, #send_file, #set_options_response, #status, #with
Constructor Details
82
83
84
|
# File 'lib/a_little_less.rb', line 82
def initialize req
@req = req
end
|
Class Method Details
.add_action(verb, action, block) ⇒ Object
69
70
71
|
# File 'lib/a_little_less.rb', line 69
def add_action verb, action, block
controllers[ self.to_s.decamelize ][ verb ][ action.to_s ] = block
end
|
.alias_name(name) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/a_little_less.rb', line 62
def alias_name name
name = name.to_s
main_name = self.to_s.decamelize
if name != main_name
alias_name_map[name] = main_name
end
end
|
.alias_name_map ⇒ Object
41
42
43
|
# File 'lib/a_little_less.rb', line 41
def alias_name_map
@@alias_name_map
end
|
.controllers ⇒ Object
38
39
40
|
# File 'lib/a_little_less.rb', line 38
def controllers
@@controllers
end
|
.default_controller ⇒ Object
56
57
58
|
# File 'lib/a_little_less.rb', line 56
def default_controller
@@default_controller = self.to_s.decamelize
end
|
.delete(action, &block) ⇒ Object
76
|
# File 'lib/a_little_less.rb', line 76
def delete action, █ add_action __method__, action, block; end
|
22
23
24
|
# File 'lib/a_little_less/env.rb', line 22
def self.env
@all_env ||= Env.new ENV['ALL_ENV']
end
|
.get(action, &block) ⇒ Object
72
|
# File 'lib/a_little_less.rb', line 72
def get action, █ add_action __method__, action, block; end
|
.get_default_controller ⇒ Object
59
60
61
|
# File 'lib/a_little_less.rb', line 59
def get_default_controller
@@default_controller
end
|
.head(action, &block) ⇒ Object
77
|
# File 'lib/a_little_less.rb', line 77
def head action, █ add_action __method__, action, block; end
|
.inherited(subclass) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/a_little_less.rb', line 44
def inherited subclass
controllers[subclass.to_s.decamelize] = {
get: {
},
head: {},
post: {},
patch: {},
put: {},
delete: {}
}
end
|
.patch(action, &block) ⇒ Object
74
|
# File 'lib/a_little_less.rb', line 74
def patch action, █ add_action __method__, action, block; end
|
.post(action, &block) ⇒ Object
73
|
# File 'lib/a_little_less.rb', line 73
def post action, █ add_action __method__, action, block; end
|
.put(action, &block) ⇒ Object
75
|
# File 'lib/a_little_less.rb', line 75
def put action, █ add_action __method__, action, block; end
|
166
167
168
|
# File 'lib/a_little_less/rack_app.rb', line 166
def self.rack_app
RackApp
end
|
Instance Method Details
#conversation! ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/a_little_less.rb', line 86
def conversation!
if http_options? and http_origin_allowed?
set_options_response
return
end
if route = search_route
action_please! route
else
not_found
end
end
|