Class: GrapeApiary::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-apiary/parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route, name, options) ⇒ Parameter

Returns a new instance of Parameter.



7
8
9
10
11
12
13
# File 'lib/grape-apiary/parameter.rb', line 7

def initialize(route, name, options)
  @full_name = name
  @name      = name
  @name      = name.scan(/\[(.*)\]/).flatten.first if name.include?('[')
  @route     = route
  @settings  = parse_options(options)
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



3
4
5
# File 'lib/grape-apiary/parameter.rb', line 3

def full_name
  @full_name
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/grape-apiary/parameter.rb', line 3

def name
  @name
end

#routeObject (readonly)

Returns the value of attribute route.



3
4
5
# File 'lib/grape-apiary/parameter.rb', line 3

def route
  @route
end

#settingsObject (readonly)

Returns the value of attribute settings.



3
4
5
# File 'lib/grape-apiary/parameter.rb', line 3

def settings
  @settings
end

Instance Method Details

#descObject



23
24
25
# File 'lib/grape-apiary/parameter.rb', line 23

def desc
  settings[:desc]
end

#descriptionObject



35
36
37
# File 'lib/grape-apiary/parameter.rb', line 35

def description
  "#{name} (#{requirement}, #{type}, `#{example}`) ... #{desc}"
end

#documentationObject



27
28
29
# File 'lib/grape-apiary/parameter.rb', line 27

def documentation
  settings[:documentation]
end

#exampleObject



31
32
33
# File 'lib/grape-apiary/parameter.rb', line 31

def example
  documentation ? documentation[:example] : nil
end

#requirementObject



15
16
17
# File 'lib/grape-apiary/parameter.rb', line 15

def requirement
  settings[:requirement]
end

#typeObject



19
20
21
# File 'lib/grape-apiary/parameter.rb', line 19

def type
  settings[:type]
end