Class: HaveAPI::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, action, resource_path) ⇒ Route

Returns a new instance of Route.



5
6
7
8
9
10
# File 'lib/haveapi/route.rb', line 5

def initialize(path, action, resource_path)
  @path = path
  @sinatra_path = path.gsub(/:([a-zA-Z\-_]+)/, '{\1}')
  @action = action
  @resource_path = resource_path
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/haveapi/route.rb', line 3

def action
  @action
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/haveapi/route.rb', line 3

def path
  @path
end

#resource_pathObject (readonly)

Returns the value of attribute resource_path.



3
4
5
# File 'lib/haveapi/route.rb', line 3

def resource_path
  @resource_path
end

#sinatra_pathObject (readonly)

Returns the value of attribute sinatra_path.



3
4
5
# File 'lib/haveapi/route.rb', line 3

def sinatra_path
  @sinatra_path
end

Instance Method Details

#descriptionObject



16
17
18
# File 'lib/haveapi/route.rb', line 16

def description
  @action.desc
end

#http_methodObject



12
13
14
# File 'lib/haveapi/route.rb', line 12

def http_method
  @action.http_method
end

#paramsObject



20
21
22
# File 'lib/haveapi/route.rb', line 20

def params
  @action.params
end