Module: Slices::PageAsJSON

Included in:
Page
Defined in:
lib/slices/page_as_json.rb

Overview

We keep this method in here to facilate easier overriding when re-opening Page.

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/slices/page_as_json.rb', line 4

def as_json(options = {})
  options ||= {}

  hash = attributes.symbolize_keys.except(:_id, :_type, :_keywords, :set_slices, :site_id).merge(
    id:        id,
    permalink: permalink,
    slices:    ordered_slices_for(options[:slice_embed]).map {|slice| slice.as_json },
    available_layouts: available_layouts,
    author: author
  )

  keys = options[:only]
  keys ? hash.slice(keys) : hash
end