Class: Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/chiro/endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Endpoint

Returns a new instance of Endpoint.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sinatra/chiro/endpoint.rb', line 4

def initialize(opts)
  @appname = opts[:appname]
  @description = opts[:description]
  @title = opts[:title]
  @verb = opts[:verb]
  @path = opts[:path]
  @named_params = opts[:named_params]
  @query_params = opts[:query_params]
  @perform_validation = opts[:perform_validation]
  @response = opts[:response]
  @forms = opts[:forms]
  @possible_errors = opts[:possible_errors]
end

Instance Attribute Details

#appnameObject (readonly)

Returns the value of attribute appname.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def appname
  @appname
end

#descriptionObject (readonly)

Returns the value of attribute description.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def description
  @description
end

#formsObject (readonly)

Returns the value of attribute forms.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def forms
  @forms
end

#named_paramsObject (readonly)

Returns the value of attribute named_params.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def named_params
  @named_params
end

#pathObject (readonly)

Returns the value of attribute path.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def path
  @path
end

#possible_errorsObject (readonly)

Returns the value of attribute possible_errors.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def possible_errors
  @possible_errors
end

#query_paramsObject (readonly)

Returns the value of attribute query_params.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def query_params
  @query_params
end

#responseObject (readonly)

Returns the value of attribute response.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def response
  @response
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def title
  @title
end

#verbObject (readonly)

Returns the value of attribute verb.



2
3
4
# File 'lib/sinatra/chiro/endpoint.rb', line 2

def verb
  @verb
end

Instance Method Details

#routeObject



19
20
21
# File 'lib/sinatra/chiro/endpoint.rb', line 19

def route
  "#{verb}: #{path}"
end

#to_json(*a) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sinatra/chiro/endpoint.rb', line 27

def to_json(*a)
  {:title => title,
   :description => description,
   :verb => verb,
   :path => path,
   :named_params => named_params,
   :query_params => query_params,
   :forms => forms,
   :possible_errors => possible_errors,
   :response => response,
   }.to_json
end

#validate?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/sinatra/chiro/endpoint.rb', line 23

def validate?
  @perform_validation
end