class SimpleParams::ApiPieDoc::NestedAttribute
Attributes
attributes[RW]
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/nested_attribute.rb, line 6 def initialize(simple_params_attribute) super self.attributes = attribute.values[0].map { |attribute| ApiPieDoc::Attribute.new(attribute) } self.options ||= attribute.delete(:options) || attribute[1] end
Public Instance Methods
name()
click to toggle source
# File lib/simple_params/api_pie_doc/nested_attribute.rb, line 12 def name attribute.keys.first.to_s end
to_s()
click to toggle source
# File lib/simple_params/api_pie_doc/nested_attribute.rb, line 16 def to_s return nil if do_not_document? nested_description end
Private Instance Methods
nested_description()
click to toggle source
# File lib/simple_params/api_pie_doc/nested_attribute.rb, line 30 def nested_description start = "param :#{name}, #{nested_type}, #{description}, #{requirement_description} do" attribute_descriptors = [] attributes.each { |attribute| attribute_descriptors << attribute.to_s } finish = "end" [start, attribute_descriptors, finish].flatten.join("\n") end
nested_type()
click to toggle source
# File lib/simple_params/api_pie_doc/nested_attribute.rb, line 22 def nested_type if options[:type].present? && options[:type].to_sym == :array 'Array' else 'Hash' end end