/lib/sinatra.fy
Unknown | 75 lines | 57 code | 18 blank | 0 comment | 0 complexity | b24b1c28ea006ca53b50206bbd78e4a4 MD5 | raw file
1require("sinatra")
2
3class Sinatra Base {
4 def self def: name with: block {
5 metaclass ruby: 'define_method args: [name] with_block: block
6 Sinatra Delegator delegate(name)
7 }
8
9 def self configure: env with: block {
10 args = [env] flatten()
11 configure(env, &block)
12 }
13
14 def self configure: block {
15 configure(&block)
16 }
17
18 def self wrap: method {
19 def: "#{method}:" with: |b | { ruby: method with_block: b }
20 def: "#{method}:do:" with: |a, b| { ruby: method args: [a] with_block: b }
21 }
22
23 def self wrapAll: methods {
24 methods each: |m| { wrap: m }
25 }
26
27 wrapAll: [
28 'get, 'put, 'post, 'delete, 'head, 'patch, 'before, 'after, 'helpers,
29 'not_found, 'template, 'layout
30 ]
31
32 def self enable: options {
33 enable(*options) flatten()
34 }
35
36 def self disable: options {
37 disable(*options) flatten()
38 }
39
40 def self set: option to: value {
41 set(option, value)
42 }
43
44 Sinatra Delegator delegate('enable:, 'disable:, 'set:to:,
45 'configure:, 'configure:with:)
46
47 forwards_unary_ruby_methods
48
49 alias_method: 'redirect: for_ruby: 'redirect
50 alias_method: 'to: for_ruby: 'to
51 alias_method: 'content_type: for_ruby: 'content_type
52
53 def self helpers: block {
54 helpers(&block)
55 }
56}
57
58class Sinatra Request {
59 forwards_unary_ruby_methods
60}
61
62class Rack Response {
63 forwards_unary_ruby_methods
64 alias_method: '[] for_ruby: '[]
65 alias_method: '[]: for_ruby: '[]=
66}
67
68class Rack Request {
69 forwards_unary_ruby_methods
70 alias_method: '[] for_ruby: '[]
71 alias_method: '[]: for_ruby: '[]=
72}
73
74
75enable: 'run