lib/locomotive/mounter/reader/api/pages_reader.rb
def filter_editable_elements(list)
            list.map do |attributes|
              type = attributes['type']
              attributes.keep_if { |k, _| %w(_id block slug content).include?(k) }.tap do |hash|
                unless hash['content'].blank?
                  if type == 'EditableFile'
                    hash['content'] = self.add_content_asset(hash['content'], '/samples/pages')
                  else
                    self.mounting_point.content_assets.each do |path, asset|
                      hash['content'].gsub!(/(http:\/\/[^\/]*)?#{path}/, asset.local_filepath)
                    end
                  end
                end
              end
            end
          end
# Only keep the minimal attributes from a list of
# editable elements hashes. It also replaces the url to
# content assets by their corresponding local ones.
#
# @param [ Array ] list The list of the editable elements with all the attributes
#
# @return [ Array ] The list of editable elements with the right attributes
#
Only keep the minimal attributes from a list of
editable elements hashes. It also replaces the url to
content assets by their corresponding local ones.
Only keep the minimal attributes from a list of editable elements hashes . It also replaces the url to content assets by their corresponding local ones .
def filter_editable_elements(list)
            list.map do |attributes|
              type = attributes['type']
              attributes.keep_if { |k, _| %w(_id block slug content).include?(k) }.tap do |hash|
                unless hash['content'].blank?
                  if type == 'EditableFile'
                    hash['content'] = self.add_content_asset(hash['content'], '/samples/pages')
                  else
                    self.mounting_point.content_assets.each do |path, asset|
                      hash['content'].gsub!(/(http:\/\/[^\/]*)?#{path}/, asset.local_filepath)
                    end
                  end
                end
              end
            end
          end
def filter_editable_elements ( list ) list . map do | attributes | type = attributes [ 'type' ] attributes . keep_if { | k , _ | %w( _id block slug content ) . include? ( k ) } . tap do | hash | unless hash [ 'content' ] . blank? if type == 'EditableFile' hash [ 'content' ] = self . add_content_asset ( hash [ 'content' ] , '/samples/pages' ) else self . mounting_point . content_assets . each do | path , asset | hash [ 'content' ] . gsub! ( / (http: \/ \/ [^ \/ ]*)? #{ path } / , asset . local_filepath ) end end end end end end
Only keep the minimal attributes from a list of
editable elements hashes.
Only keep the minimal attributes from a list of editable elements hashes .
The list of editable elements with the right attributes
The list of editable elements with the right attributes
 Array 
list
list The list of the editable elements with all the attributes
list The list of the editable elements with all the attributes