class SimpleParams::ApiPieDoc::Attribute
Public Class Methods
new(simple_params_attribute)
click to toggle source
Calls superclass method
SimpleParams::ApiPieDoc::AttributeBase::new
# File lib/simple_params/api_pie_doc/attribute.rb, line 4 def initialize(simple_params_attribute) super self.options ||= attribute[1] end
Public Instance Methods
name()
click to toggle source
# File lib/simple_params/api_pie_doc/attribute.rb, line 9 def name attribute[0].to_s end
to_s()
click to toggle source
# File lib/simple_params/api_pie_doc/attribute.rb, line 13 def to_s return nil if do_not_document? attribute_description end
Private Instance Methods
attribute_description()
click to toggle source
# File lib/simple_params/api_pie_doc/attribute.rb, line 20 def attribute_description base = "param :#{name}" [base, type_description, description, requirement_description].reject(&:blank?).join(", ") end
type_description()
click to toggle source
# File lib/simple_params/api_pie_doc/attribute.rb, line 25 def type_description value = options[:type] case value when :string, :integer, :array, :hash, :object, :date "#{value.to_s.capitalize.constantize}" when 'String', 'Integer', 'Array', 'Hash', 'Date' "#{value}" when :boolean 'Boolean' when :decimal, :datetime, :time, :float "" else raise NotValidValueError.new("Must be one of #{SimpleParams::Params::TYPES}") end end