Sha256: 2a0c2dfb966279c18f05c6bf2a5f779a5b38e7bfb94d4e466049cc7f824cd6fc

Contents?: true

Size: 656 Bytes

Versions: 28

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

class PageResource
  include Alba::Resource

  attributes :id, :parent_page_id, :locale
  attributes(*PagesCore::Templates::TemplateConfiguration.all_blocks)
  attributes :published_at, :pinned

  attribute :param do
    object.to_param
  end

  attribute :image do
    image_resource(object.page_images.where(primary: true).try(:first))
  end

  attribute :images do
    object.page_images.map { |image| image_resource(image) }
  end

  attribute :pages do
    object.pages.map { |p| PageResource.new(p) }
  end

  private

  def image_resource(image)
    return nil unless image

    PageImageResource.new(image)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pages_core-3.10.1 app/resources/page_resource.rb
pages_core-3.9.2 app/resources/page_resource.rb
pages_core-3.9.1 app/resources/page_resource.rb
pages_core-3.9.0 app/resources/page_resource.rb
pages_core-3.8.3 app/resources/page_resource.rb
pages_core-3.8.2 app/resources/page_resource.rb
pages_core-3.8.1 app/resources/page_resource.rb
pages_core-3.8.0 app/resources/page_resource.rb