Class: SimpleParams::ApiPieDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_params/api_pie_doc.rb

Defined Under Namespace

Classes: Attribute, AttributeBase, NestedArray, NestedAttribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(simple_params) ⇒ ApiPieDoc



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_params/api_pie_doc.rb', line 11

def initialize(simple_params)
  self.base_attributes = simple_params.defined_attributes
  self.nested_hashes = simple_params.nested_hashes
  self.nested_arrays = simple_params.nested_arrays
  self.nested_attributes = []
  self.nested_array_attributes = []
  self.docs = []

  build_nested_attributes
  build_nested_array_attributes
end

Instance Attribute Details

#base_attributesObject

Returns the value of attribute base_attributes.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def base_attributes
  @base_attributes
end

#docsObject

Returns the value of attribute docs.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def docs
  @docs
end

#nested_array_attributesObject

Returns the value of attribute nested_array_attributes.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def nested_array_attributes
  @nested_array_attributes
end

#nested_arraysObject

Returns the value of attribute nested_arrays.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def nested_arrays
  @nested_arrays
end

#nested_attributesObject

Returns the value of attribute nested_attributes.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def nested_attributes
  @nested_attributes
end

#nested_hashesObject

Returns the value of attribute nested_hashes.



4
5
6
# File 'lib/simple_params/api_pie_doc.rb', line 4

def nested_hashes
  @nested_hashes
end

Instance Method Details

#buildObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/simple_params/api_pie_doc.rb', line 23

def build
  base_attributes.each do |attribute|
    docs << Attribute.new(attribute).to_s
  end

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

  nested_array_attributes.each do |nested_attribute|
    docs << NestedArray.new(nested_attribute).to_s
  end

  docs.join("\n")
end