Class: GrapeDoc::APIParameter
- Inherits:
-
Object
- Object
- GrapeDoc::APIParameter
- Defined in:
- lib/grape_doc/api_parameter.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#field ⇒ Object
Returns the value of attribute field.
-
#field_type ⇒ Object
Returns the value of attribute field_type.
-
#required ⇒ Object
Returns the value of attribute required.
-
#sample_value ⇒ Object
Returns the value of attribute sample_value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parameter_name = nil, parameter_hash = nil) ⇒ APIParameter
constructor
A new instance of APIParameter.
Constructor Details
#initialize(parameter_name = nil, parameter_hash = nil) ⇒ APIParameter
Returns a new instance of APIParameter.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/grape_doc/api_parameter.rb', line 8 def initialize(parameter_name = nil, parameter_hash = nil) return if parameter_name.nil? or parameter_hash.nil? or parameter_hash.empty? or parameter_name.empty? self.field = parameter_name.to_s self.required = parameter_hash[:requires] || parameter_hash[:required] self.description = parameter_hash[:desc] || parameter_hash[:description] self.field_type = parameter_hash[:type] if parameter_hash.keys.include? :documentation self.sample_value = parameter_hash[:documentation][:example] end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/grape_doc/api_parameter.rb', line 3 def description @description end |
#field ⇒ Object
Returns the value of attribute field.
3 4 5 |
# File 'lib/grape_doc/api_parameter.rb', line 3 def field @field end |
#field_type ⇒ Object
Returns the value of attribute field_type.
3 4 5 |
# File 'lib/grape_doc/api_parameter.rb', line 3 def field_type @field_type end |
#required ⇒ Object
Returns the value of attribute required.
3 4 5 |
# File 'lib/grape_doc/api_parameter.rb', line 3 def required @required end |
#sample_value ⇒ Object
Returns the value of attribute sample_value.
3 4 5 |
# File 'lib/grape_doc/api_parameter.rb', line 3 def sample_value @sample_value end |
Class Method Details
.initialize_parameters(params_hash) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/grape_doc/api_parameter.rb', line 24 def self.initialize_parameters(params_hash) params = params_hash.map do |name, hash| APIParameter.new(name, hash) end return nil if params.empty? params end |