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.15.5 app/resources/page_resource.rb
pages_core-3.15.4 app/resources/page_resource.rb
pages_core-3.15.3 app/resources/page_resource.rb
pages_core-3.15.2 app/resources/page_resource.rb
pages_core-3.15.1 app/resources/page_resource.rb
pages_core-3.14.0 app/resources/page_resource.rb
pages_core-3.13.0 app/resources/page_resource.rb
pages_core-3.12.7 app/resources/page_resource.rb
pages_core-3.12.6 app/resources/page_resource.rb
pages_core-3.12.5 app/resources/page_resource.rb
pages_core-3.12.4 app/resources/page_resource.rb
pages_core-3.12.3 app/resources/page_resource.rb
pages_core-3.12.2 app/resources/page_resource.rb
pages_core-3.12.1 app/resources/page_resource.rb
pages_core-3.12.0 app/resources/page_resource.rb
pages_core-3.11.3 app/resources/page_resource.rb
pages_core-3.11.2 app/resources/page_resource.rb
pages_core-3.11.1 app/resources/page_resource.rb
pages_core-3.11.0 app/resources/page_resource.rb
pages_core-3.10.2 app/resources/page_resource.rb