Sha256: d52e9fa585408e5259976f12860835ad9adb0163509802aa202d786c86431e9a

Contents?: true

Size: 623 Bytes

Versions: 4

Compression:

Stored size: 623 Bytes

Contents

def route_prefix
  @route_prefix ||= []
  File.join(["/"] + @route_prefix)
end

def add_route(what, verb)
  raise InvalidRoute unless what.is_a? Hash
  what[:url] = File.expand_path File.join(route_prefix, what[:url])
  Nephos::Router.check!(what)
  Nephos::Router.add_params!(what)
  Nephos::Router.add(what, verb)
end

# @param what [Hash]
def get what
  add_route what, "GET"
end

# @param what [Hash]
def post what
  add_route what, "POST"
end

# @param what [Hash]
def put what
  add_route what, "PUT"
end

def resource(name, &block)
  @route_prefix ||= []
  @route_prefix << name
  block.call
  @route_prefix.pop
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nephos-server-0.4.2 lib/nephos-server/router/helpers.rb
nephos-server-0.4.1 lib/nephos-server/router/helpers.rb
nephos-server-0.4.0 lib/nephos-server/router/helpers.rb
nephos-server-0.3.2 lib/nephos-server/router/helpers.rb