Class: Alchemy::JsonApi::Page

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/models/alchemy/json_api/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, page_version_type: :public_version) ⇒ Page

Returns a new instance of Page.



12
13
14
15
16
# File 'app/models/alchemy/json_api/page.rb', line 12

def initialize(page, page_version_type: :public_version)
  @page_version_type = page_version_type
  @page_version = page.public_send(page_version_type)
  super(page)
end

Instance Attribute Details

#page_versionObject (readonly)

Returns the value of attribute page_version.



10
11
12
# File 'app/models/alchemy/json_api/page.rb', line 10

def page_version
  @page_version
end

#page_version_typeObject (readonly)

Returns the value of attribute page_version_type.



10
11
12
# File 'app/models/alchemy/json_api/page.rb', line 10

def page_version_type
  @page_version_type
end

Instance Method Details

#all_element_idsObject



33
34
35
# File 'app/models/alchemy/json_api/page.rb', line 33

def all_element_ids
  @_all_element_ids ||= all_elements.map(&:id)
end

#all_elementsObject

All elements including nested and fixed elements



19
20
21
# File 'app/models/alchemy/json_api/page.rb', line 19

def all_elements
  @_all_elements ||= element_repository
end

#ancestor_idsObject



45
46
47
# File 'app/models/alchemy/json_api/page.rb', line 45

def ancestor_ids
  @_ancestor_ids ||= ancestors.map(&:id)
end

#element_idsObject



37
38
39
# File 'app/models/alchemy/json_api/page.rb', line 37

def element_ids
  @_element_ids ||= elements.map(&:id)
end

#elementsObject

Not nested unfixed top level elements



24
25
26
# File 'app/models/alchemy/json_api/page.rb', line 24

def elements
  @_elements ||= element_repository.not_nested.unfixed
end

#fixed_element_idsObject



41
42
43
# File 'app/models/alchemy/json_api/page.rb', line 41

def fixed_element_ids
  @_fixed_element_ids ||= fixed_elements.map(&:id)
end

#fixed_elementsObject

Not nested fixed top level elements



29
30
31
# File 'app/models/alchemy/json_api/page.rb', line 29

def fixed_elements
  @_fixed_elements ||= element_repository.not_nested.fixed
end