alchemy-json_api 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97db79acd9c6dfb19a865b855f4fe4849fda6ed306684aebc0006f6e8a0c491a
4
- data.tar.gz: 3863316005bf0fa85f03a2605ef6f0e295e3115b7cb17f9dd4de9e866a2b50a6
3
+ metadata.gz: ec8c154e4f6ac5ba72d6d96b39a60475acf9b0d411d3a4e2d34c81fc271d1489
4
+ data.tar.gz: c0cc273e02b2038e5462428fa1f7d0960be37ccf8225abd76af7343ca4f76ec0
5
5
  SHA512:
6
- metadata.gz: 8c52e8ec6c28505682e6469990e4b24c6eb365de7f8ddc05b5b8d0e1a4831e7852e7bb502e95c475ac19af4bafd4402148a0693cdacb7f0f1be715b891b686aa
7
- data.tar.gz: 554481f252201637ce0daf5ca3429fd456c0ec82b34928dc9f0f959f4f4aaee7ee85923f5a9151548725130d6a5a21c03bc2a2e108163ad16e8a60c5a68b259c
6
+ metadata.gz: 2f0ebd08816a2d97347555eaf114735b429ec7c1e2592f9c1ff0b652be9f0799c782489987eac5d3142d5f5246ac6f02375460d62931ef4cfcca4f8a3e9ad809
7
+ data.tar.gz: '08c7a5e5570c995b3495844bcceb9a145173cb3e224fce0051a5b672eae408aee58850e1b612fb25051c0896c571365481daabe28d7e4766b62742e1b0363e34'
@@ -5,7 +5,7 @@ module Alchemy
5
5
  private
6
6
 
7
7
  def base_page_scope
8
- Page.all
8
+ ::Alchemy::JsonApi::Page.all
9
9
  end
10
10
 
11
11
  def page_scope
@@ -50,7 +50,7 @@ module Alchemy
50
50
  def page_scope_with_includes
51
51
  base_page_scope.
52
52
  with_language(Language.current).
53
- preload(language: { nodes: [:parent, :page] }, all_elements: { contents: { essence: :ingredient_association } })
53
+ preload(language: { nodes: [:parent, :page, :children] }, all_elements: { contents: { essence: :ingredient_association } })
54
54
  end
55
55
 
56
56
  def base_page_scope
@@ -12,14 +12,14 @@ module Alchemy
12
12
  scope :available, -> { where(public: true).where.not(position: nil) }
13
13
 
14
14
  def parent_element
15
- page.elements.detect do |element|
15
+ page.all_elements.detect do |element|
16
16
  element.id == parent_element_id
17
17
  end
18
18
  end
19
19
 
20
20
  def nested_elements
21
21
  @_nested_elements ||= begin
22
- page.elements.select do |element|
22
+ page.all_elements.select do |element|
23
23
  element.parent_element_id == id
24
24
  end
25
25
  end
@@ -23,17 +23,13 @@ module Alchemy
23
23
  # The top level public, non-fixed elements of this page that - if present -
24
24
  # contains their nested_elements.
25
25
  def elements
26
- @_elements ||= all_elements.select do |element|
27
- !element.fixed? || element.parent_element_id.nil?
28
- end
26
+ @_elements ||= first_level_elements.reject(&:fixed?)
29
27
  end
30
28
 
31
29
  # The top level public, fixed elements of this page that - if present -
32
30
  # contains their nested_elements.
33
31
  def fixed_elements
34
- @_fixed_elements ||= all_elements.select do |element|
35
- element.fixed? || element.parent_element_id.nil?
36
- end
32
+ @_fixed_elements ||= first_level_elements.select(&:fixed?)
37
33
  end
38
34
 
39
35
  def element_ids
@@ -43,6 +39,12 @@ module Alchemy
43
39
  def fixed_element_ids
44
40
  @_fixed_element_ids ||= fixed_elements.map(&:id)
45
41
  end
42
+
43
+ private
44
+
45
+ def first_level_elements
46
+ @_first_level_elements ||= all_elements.reject(&:parent_element_id)
47
+ end
46
48
  end
47
49
  end
48
50
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
3
  module JsonApi
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-21 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms