Module: Angelo::Base::DSL
- Included in:
- Angelo::Base
- Defined in:
- lib/angelo/base.rb,
lib/angelo/main.rb
Overview
Takes a block and/or modules that define methods that can be used from within request handlers. Methods can also be defined at the top level but they get defined as Object instance methods which isn’t good.
Instance Method Summary collapse
- #addr(a = nil) ⇒ Object
- #after(opts = {}, &block) ⇒ Object
- #before(opts = {}, &block) ⇒ Object
- #eventsource(path, headers = nil, &block) ⇒ Object
- #helpers(*args, &block) ⇒ Object
- #log_level(ll = nil) ⇒ Object
- #on_pong(&block) ⇒ Object
- #ping_time(pt = nil) ⇒ Object
- #port(p = nil) ⇒ Object
- #public_dir(d = nil) ⇒ Object
- #report_errors! ⇒ Object
- #task(name, &block) ⇒ Object
- #views_dir(d = nil) ⇒ Object
- #websocket(path, &block) ⇒ Object
Instance Method Details
#addr(a = nil) ⇒ Object
62 63 64 65 |
# File 'lib/angelo/base.rb', line 62 def addr a = nil @addr = a if a @addr end |
#after(opts = {}, &block) ⇒ Object
123 124 125 |
# File 'lib/angelo/base.rb', line 123 def after opts = {}, &block filter :after, opts, &block end |
#before(opts = {}, &block) ⇒ Object
119 120 121 |
# File 'lib/angelo/base.rb', line 119 def before opts = {}, &block filter :before, opts, &block end |
#eventsource(path, headers = nil, &block) ⇒ Object
110 111 112 113 |
# File 'lib/angelo/base.rb', line 110 def eventsource path, headers = nil, &block path = ::Mustermann.new path routes[:get][path] = Responder::Eventsource.new headers, &block end |
#helpers(*args, &block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/angelo/main.rb', line 13 def helpers(*args, &block) args.each do |mod| include(mod) end block && class_exec(&block) end |
#log_level(ll = nil) ⇒ Object
67 68 69 70 |
# File 'lib/angelo/base.rb', line 67 def log_level ll = nil @log_level = ll if ll @log_level end |
#on_pong(&block) ⇒ Object
127 128 129 |
# File 'lib/angelo/base.rb', line 127 def on_pong &block Responder::Websocket.on_pong = block end |
#ping_time(pt = nil) ⇒ Object
72 73 74 75 |
# File 'lib/angelo/base.rb', line 72 def ping_time pt = nil @ping_time = pt if pt @ping_time end |
#port(p = nil) ⇒ Object
77 78 79 80 |
# File 'lib/angelo/base.rb', line 77 def port p = nil @port = p if p @port end |
#public_dir(d = nil) ⇒ Object
88 89 90 91 92 |
# File 'lib/angelo/base.rb', line 88 def public_dir d = nil @public_dir = d if d @public_dir ||= DEFAULT_PUBLIC_DIR File.join root, @public_dir end |
#report_errors! ⇒ Object
94 95 96 |
# File 'lib/angelo/base.rb', line 94 def report_errors! @report_errors = true end |
#task(name, &block) ⇒ Object
115 116 117 |
# File 'lib/angelo/base.rb', line 115 def task name, &block Angelo::Server.define_task name, &block end |
#views_dir(d = nil) ⇒ Object
82 83 84 85 86 |
# File 'lib/angelo/base.rb', line 82 def views_dir d = nil @views_dir = d if d @views_dir ||= DEFAULT_VIEWS_DIR File.join root, @views_dir end |
#websocket(path, &block) ⇒ Object
105 106 107 108 |
# File 'lib/angelo/base.rb', line 105 def websocket path, &block path = ::Mustermann.new path routes[:websocket][path] = Responder::Websocket.new &block end |