Sha256: 8e6be9ab65c3769d2d8bd401945b995292204296a14dbf37043d5a94fb26e610
Contents?: true
Size: 629 Bytes
Versions: 37
Compression:
Stored size: 629 Bytes
Contents
# frozen_string_literal: true module Spotlight module PageContent # Sir-Trevor created content class SirTrevor def self.parse(page, attribute) blocks = page.read_attribute(attribute) blocks ||= [].to_json return [] if blocks.blank? blocks = JSON.parse(blocks, symbolize_names: true) if blocks.is_a?(String) if blocks.is_a?(Hash) blocks = blocks[:data] || blocks['data'] or raise IndexError, 'No block data found' end blocks.map do |obj| SirTrevorRails::Block.from_hash(obj, page) end end end end end
Version data entries
37 entries across 37 versions & 1 rubygems