module Jellyfish::DSL


Public Instance Methods

controller(value=GetValue) click to toggle source
# File lib/jellyfish.rb, line 146
def controller value=GetValue
  if value == GetValue
    @controller ||= controller_inject(
      const_set(:Controller, Class.new(Controller)))
  else
    @controller   = controller_inject(value)
  end
end
controller_include(*value) click to toggle source
# File lib/jellyfish.rb, line 142
def controller_include *value
  (@controller_include ||= []).push(*value)
end
controller_inject(value) click to toggle source
# File lib/jellyfish.rb, line 155
def controller_inject value
  controller_include.
    inject(value){ |ctrl, mod| ctrl.__send__(:include, mod) }
end
define(method, route=//, meta={}, &block) click to toggle source
# File lib/jellyfish.rb, line 166
def define(method, route=//, meta={}, &block)
  raise TypeError.new("Route #{route} should respond to :match") \
    unless route.respond_to?(:match)

  (routes[method.to_s] ||= []) << [route, block || lambda{|_|}, meta]
end
handle(*exceptions, &block) click to toggle source
# File lib/jellyfish.rb, line 131
def handle *exceptions, &block
  exceptions.each{ |exp| handlers[exp] = block }
end
handle_exceptions(value=GetValue) click to toggle source
# File lib/jellyfish.rb, line 134
def handle_exceptions value=GetValue
  if value == GetValue
    @handle_exceptions
  else
    @handle_exceptions = value
  end
end
handlers() click to toggle source
# File lib/jellyfish.rb, line 130
def handlers; @handlers ||= {}; end
inherited(sub) click to toggle source
# File lib/jellyfish.rb, line 173
def inherited sub
  sub.handle_exceptions(handle_exceptions)
  sub.controller_include(*controller_include)
  [:handlers, :routes].each{ |m|
    val = __send__(m).inject({}){ |r, (k, v)| r[k] = v.dup; r }
    sub.__send__(m).replace(val) # dup the routing arrays
  }
end
routes() click to toggle source
# File lib/jellyfish.rb, line 129
def routes  ; @routes   ||= {}; end