module Angelo::Base::DSL

Methods defined in module DSL will be available in the DSL both in Angelo::Base subclasses as class methods and, if angelo/main is required, in the top level DSL by forwarding to an anonymous Angelo::Base subclass.

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.

Public Instance Methods

addr(a = nil) click to toggle source
# File lib/angelo/base.rb, line 23
def addr a = nil
  @addr = a if a
  @addr
end
after(opts = {}) click to toggle source
# File lib/angelo/base.rb, line 86
def after opts = {}, &block
  filter :after, opts, &block
end
before(opts = {}) click to toggle source
# File lib/angelo/base.rb, line 82
def before opts = {}, &block
  filter :before, opts, &block
end
content_type(type) click to toggle source
# File lib/angelo/base.rb, line 95
def content_type type
  Responder.content_type type
end
default_headers(hs) click to toggle source
# File lib/angelo/base.rb, line 99
def default_headers hs
  Responder.default_headers = Responder.default_headers.merge hs
end
eventsource(path, headers = nil, &block) click to toggle source
# File lib/angelo/base.rb, line 73
def eventsource path, headers = nil, &block
  path = ::Mustermann.new path
  routes[:get][path] = Responder::Eventsource.new headers, &block
end
helpers(*args, &block) click to toggle source
# 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) click to toggle source
# File lib/angelo/base.rb, line 33
def log_level ll = nil
  @log_level = ll if ll
  @log_level
end
on_pong(&block) click to toggle source
# File lib/angelo/base.rb, line 90
def on_pong &block
  @on_pong = block if block
  @on_pong
end
ping_time(pt = nil) click to toggle source
# File lib/angelo/base.rb, line 38
def ping_time pt = nil
  @ping_time = pt if pt
  @ping_time
end
port(p = nil) click to toggle source
# File lib/angelo/base.rb, line 28
def port p = nil
  @port = p if p
  @port
end
public_dir(d = nil) click to toggle source
# File lib/angelo/base.rb, line 52
def public_dir d = nil
  @public_dir = d if d
  File.join root, @public_dir
end
reload_templates!(on = true) click to toggle source
# File lib/angelo/base.rb, line 48
def reload_templates!(on = true)
  @reload_templates = on
end
report_errors!() click to toggle source
# File lib/angelo/base.rb, line 57
def report_errors!
  @report_errors = true
end
task(name, &block) click to toggle source
# File lib/angelo/base.rb, line 78
def task name, &block
  Angelo::Server.define_task name, &block
end
views_dir(d = nil) click to toggle source
# File lib/angelo/base.rb, line 43
def views_dir d = nil
  @views_dir = d if d
  File.join root, @views_dir
end
websocket(path, &block) click to toggle source
# File lib/angelo/base.rb, line 68
def websocket path, &block
  path = ::Mustermann.new path
  routes[:websocket][path] = Responder::Websocket.new nil, &block
end