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

Version Path
blacklight-spotlight-4.3.6 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.5 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.4 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.3 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.2 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.1 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.3.0 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.2.0 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.1.2 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.1.1 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.1.0 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.0.3 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.0.2 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.0.1 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-4.0.0 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-3.6.0.beta10 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-3.6.0.beta9 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-3.6.0.beta8 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-3.5.0.4 app/models/spotlight/page_content/sir_trevor.rb
blacklight-spotlight-3.6.0.beta7 app/models/spotlight/page_content/sir_trevor.rb