Sha256: 156ebcc634ca7e21607281ad346813d6a2981e9665de1af5d9238b8c4a1fd9ea
Contents?: true
Size: 774 Bytes
Versions: 3
Compression:
Stored size: 774 Bytes
Contents
require 'roar/decorator' require 'roar/json' module Spotlight class PageRepresenter < Roar::Decorator include Roar::JSON (Spotlight::Page.attribute_names - ['id', 'scope', 'exhibit_id', 'parent_page_id', 'content']).each do |prop| property prop end property :content, exec_context: :decorator def content # get the sir-trevor objects as JSON. represented.content.as_json end def content= content represented.content = content end end class NestedPageRepresenter < PageRepresenter collection :child_pages, parse_strategy: lambda { |fragment, i, options| options.represented.child_pages.find_or_initialize_by(slug: fragment['slug']) }, class: Spotlight::FeaturePage, extend: NestedPageRepresenter end end
Version data entries
3 entries across 3 versions & 1 rubygems