class SimpleParams::ApiPieDoc

Attributes

base_attributes[RW]
docs[RW]
nested_attributes[RW]
nested_classes[RW]

Public Class Methods

new(simple_params) click to toggle source
# File lib/simple_params/api_pie_doc.rb, line 9
def initialize(simple_params)
  self.base_attributes = simple_params.defined_attributes
  self.nested_classes = simple_params.nested_classes
  self.nested_attributes = []
  self.docs = []

  build_nested_classes
end

Public Instance Methods

build() click to toggle source
# File lib/simple_params/api_pie_doc.rb, line 18
def build
  base_attributes.each do |attribute|
    docs << Attribute.new(attribute).to_s
  end

  nested_attributes.each do |nested_class|
    docs << NestedAttribute.new(nested_class).to_s
  end

  docs.join("\n")
end

Private Instance Methods

build_nested_classes() click to toggle source
# File lib/simple_params/api_pie_doc.rb, line 32
def build_nested_classes
  nested_classes.each do |name, parameter_set|
    nested_attributes << { name => parameter_set.defined_attributes, options: parameter_set.options }
  end
end