lib/praxis/docs/generator.rb
# Data: hash/array structure of dumped resources and/or types
# processed_types: list of type classes that have already gone through a describe+collect (this or previous rounds)
# ... any processed type won't need to be described+reached any longer
# newly_found: list of type classes that have been seen in the search (and that weren't already in the processed type)
hash/array structure of dumped resources and/or types
processed_types: list of type classes that have already gone through a describe+collect (this or previous rounds)
any processed type won't need to be described+reached any longer
newly_found: list of type classes that have been seen in the search (and that weren't already in the processed type)
hash / array structure of dumped resources and / or types processed_types : list of type classes that have already gone through a describe + collect ( this or previous rounds ) any processed type won ' t need to be described + reached any longer newly_found : list of type classes that have been seen in the search ( and that weren ' t already in the processed type )
def scan_dump_for_types( data, processed_types )
        newfound_types = Set.new
        case data
        when Array
          data.collect{|item| newfound_types += scan_dump_for_types( item , processed_types ) }
        when Hash
          if data.key?(:type) && data[:type].kind_of?(Hash) && ( [:id,:name,:family] - data[:type].keys ).empty?
            type_id = data[:type][:id]
            unless type_id.nil? || type_id == Praxis::SimpleMediaType.id 
              unless types_by_id[type_id]
                raise "Error! We have detected a reference to a 'Type' with id='#{type_id}' which is not derived from Attributor::Type" +
                      " Document generation cannot proceed."
              end
              newfound_types << types_by_id[type_id] unless processed_types.include? types_by_id[type_id]
            end
          end
          data.values.map{|item| newfound_types += scan_dump_for_types( item , processed_types)}
        end
        newfound_types
      end
def scan_dump_for_types ( data , processed_types ) newfound_types = Set . new case data when Array data . collect { | item | newfound_types += scan_dump_for_types ( item , processed_types ) } when Hash if data . key? ( :type ) && data [ :type ] . kind_of? ( Hash ) && ( [ :id , :name , :family ] - data [ :type ] . keys ) . empty? type_id = data [ :type ] [ :id ] unless type_id . nil? || type_id == Praxis :: SimpleMediaType . id unless types_by_id [ type_id ] raise "Error! We have detected a reference to a 'Type' with id='#{type_id}' which is not derived from Attributor::Type" + " Document generation cannot proceed." end newfound_types << types_by_id [ type_id ] unless processed_types . include? types_by_id [ type_id ] end end data . values . map { | item | newfound_types += scan_dump_for_types ( item , processed_types ) } end newfound_types end
Data: hash/array structure of dumped resources and/or types
processed_types: list of type classes that have already gone through a describe+collect (this or previous rounds)
... any processed type won't need to be described+reached any longer
newly_found: list of type classes that have been seen in the search (and that weren't already in the processed type)
Data : hash / array structure of dumped resources and / or types processed_types : list of type classes that have already gone through a describe + collect ( this or previous rounds ) ... any processed type won ' t need to be described + reached any longer newly_found : list of type classes that have been seen in the search ( and that weren ' t already in the processed type )
#SimpleTypes shouldn't be collected
data
<not_specific>
processed_types
<not_specific>