Sha256: a57a2273d9bc7c364a1a124c163698d842e85687d7cfb241066b828f9161c74d

Contents?: true

Size: 646 Bytes

Versions: 7

Compression:

Stored size: 646 Bytes

Contents

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

def add_route(verb, what)
  raise InvalidRoute, "what must be a hash" 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 "GET", what
end

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nephos-server-0.5.0 lib/nephos-server/router/helpers.rb
nephos-server-0.4.8 lib/nephos-server/router/helpers.rb
nephos-server-0.4.7 lib/nephos-server/router/helpers.rb
nephos-server-0.4.6 lib/nephos-server/router/helpers.rb
nephos-server-0.4.5 lib/nephos-server/router/helpers.rb
nephos-server-0.4.4 lib/nephos-server/router/helpers.rb
nephos-server-0.4.3 lib/nephos-server/router/helpers.rb