Class: JaxrsDoc::Resource

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/annotations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name, type_annotations, verbs_annotations = {}, type_description = nil, params_descriptions = {}) ⇒ Resource

Returns a new instance of Resource.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/annotations.rb', line 8

def initialize(file_name, type_annotations, verbs_annotations = {}, type_description = nil, params_descriptions = {})
  @name = file_name
  @description = type_description
  @params_descriptions = params_descriptions
  @path = type_annotations.annotations.find {|a| a.name.eql?"Path"}
  @consumes = type_annotations.annotations.find {|a| a.name.eql?"Consumes"}
  @gets = verbs_annotations[:gets]
  @posts = verbs_annotations[:posts]
  @puts = verbs_annotations[:puts]
  @deletes = verbs_annotations[:deletes]
  @verbs = verbs_annotations
end

Instance Attribute Details

#consumesObject (readonly)

Returns the value of attribute consumes.



6
7
8
# File 'lib/annotations.rb', line 6

def consumes
  @consumes
end

#deletesObject (readonly)

Returns the value of attribute deletes.



6
7
8
# File 'lib/annotations.rb', line 6

def deletes
  @deletes
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/annotations.rb', line 6

def description
  @description
end

#getsObject (readonly)

Returns the value of attribute gets.



6
7
8
# File 'lib/annotations.rb', line 6

def gets
  @gets
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/annotations.rb', line 6

def name
  @name
end

#params_descriptionsObject (readonly)

Returns the value of attribute params_descriptions.



6
7
8
# File 'lib/annotations.rb', line 6

def params_descriptions
  @params_descriptions
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/annotations.rb', line 6

def path
  @path
end

#postsObject (readonly)

Returns the value of attribute posts.



6
7
8
# File 'lib/annotations.rb', line 6

def posts
  @posts
end

#putsObject (readonly)

Returns the value of attribute puts.



6
7
8
# File 'lib/annotations.rb', line 6

def puts
  @puts
end

#verbsObject (readonly)

Returns the value of attribute verbs.



6
7
8
# File 'lib/annotations.rb', line 6

def verbs
  @verbs
end

Instance Method Details

#<=>(another) ⇒ Object



29
30
31
# File 'lib/annotations.rb', line 29

def <=>(another)
  path.value <=> another.path.value
end

#add_param_description(param_description) ⇒ Object



25
26
27
# File 'lib/annotations.rb', line 25

def add_param_description(param_description)
  @params_descriptions.update(param_description)
end

#get_bindingObject

Support ERB templating of member data.



38
39
40
# File 'lib/annotations.rb', line 38

def get_binding
  binding
end

#to_sObject



33
34
35
# File 'lib/annotations.rb', line 33

def to_s
  "#{@name} [#{@path.value}]"  
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/annotations.rb', line 21

def valid?
  not @path.nil?
end