alchemy-json_api 0.1.0 → 0.2.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: 25ba34a50a58c59ff4aabb21089faee49c5ada8fbbf753a1515799845bea8213
4
- data.tar.gz: 247cf1d183feda62cec526e9a7ceec96716ff1ed97589a473ba86193cfd54065
3
+ metadata.gz: cf27f9f29046c7ad0e2d417d3c9cca5e0d58d59c7bc729119d76f37adeaa4b28
4
+ data.tar.gz: 697deefd22185ca5df6811f9687129e34c33e445feacae02f71fd045f5e96830
5
5
  SHA512:
6
- metadata.gz: 1facc4daccad62f6b80c8c7494c644621713ed048e8dcc8cfb55abdeb2b3fb115f519c835febd7ebb509b6dab3d9a0e43ea2837ed6aa71d863d7b6942de001ec
7
- data.tar.gz: 57c7d49f5214edbc140303a7be3a4286b6649eff07905f3eba4fa74531e27444ab24b8976a983855d1a70adaf961a639c246f12a0737e269872213f454e402cc
6
+ metadata.gz: 9d6fc09988a259d084f4e34440985dbe85122c191342bf7b4b722b559f1e3d9500ffd7ab3e6e4c32748a946305ca5b96fc0ff13fcb9236d73626b57116e8bf70
7
+ data.tar.gz: 139fc4a4b1e17957dd1cddad50a6f26601e773adb5b83b41a0fb2234cddc58d6f9aa24f24000f00607fa64cee0d3e7304105f396204c9c72fcd50c500e1d3460
@@ -6,6 +6,7 @@ module Alchemy
6
6
  include JSONAPI::Fetching
7
7
  include JSONAPI::Errors
8
8
  include JSONAPI::Filtering
9
+ include JSONAPI::Pagination
9
10
  end
10
11
  end
11
12
  end
@@ -8,7 +8,9 @@ module Alchemy
8
8
  allowed = [:page_layout]
9
9
 
10
10
  jsonapi_filter(page_scope, allowed) do |filtered|
11
- render jsonapi: filtered.result
11
+ jsonapi_paginate(filtered.result) do |paginated|
12
+ render jsonapi: paginated
13
+ end
12
14
  end
13
15
  end
14
16
 
@@ -18,6 +20,15 @@ module Alchemy
18
20
 
19
21
  private
20
22
 
23
+ def jsonapi_meta(pages)
24
+ pagination = jsonapi_pagination_meta(pages)
25
+
26
+ {
27
+ pagination: pagination.presence,
28
+ total: page_scope.count
29
+ }.compact
30
+ end
31
+
21
32
  def load_page
22
33
  @page = load_page_by_id || load_page_by_urlname || raise(ActiveRecord::RecordNotFound)
23
34
  end
@@ -8,7 +8,7 @@ module Alchemy::JsonApi
8
8
  :updated_at,
9
9
  )
10
10
  attribute :element_type, &:name
11
- belongs_to :parent_element, record_type: :element
11
+ belongs_to :parent_element, record_type: :element, serializer: self
12
12
 
13
13
  belongs_to :page
14
14
  has_many :essences, polymorphic: true do |element|
@@ -9,7 +9,7 @@ module Alchemy
9
9
  attribute :link_title, &:title
10
10
  attribute :link_nofollow, &:nofollow
11
11
 
12
- belongs_to :parent, record_type: :node
12
+ belongs_to :parent, record_type: :node, serializer: self
13
13
 
14
14
  has_many :children, record_type: :node, serializer: self
15
15
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
3
  module JsonApi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fast_jsonapi
29
29
  requirement: !ruby/object:Gem::Requirement