Method: Praxis::Types::MultipartArray.example

Defined in:
lib/praxis/types/multipart_array.rb

.example(context = Attributor::DEFAULT_ROOT_CONTEXT, **options) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/praxis/types/multipart_array.rb', line 135

def self.example(context=Attributor::DEFAULT_ROOT_CONTEXT, **options)
  example = self.new

  self.attributes.each do |name, attribute|
    next if name.kind_of? Regexp
    sub_context = self.generate_subcontext(context, name)

    part = attribute.example(sub_context)
    part.name = name
    example.push part

    if self.multiple.include? name
      part = attribute.example(sub_context + ['2'])
      part.name = name
      example.push part
    end
  end

  example
end