activeset 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0342d1f291390f1b5e3e0654409d9071f381dc8f
4
- data.tar.gz: 83c5079292686ff333a02c502b9018760067fb91
3
+ metadata.gz: 7d5e68a1195e14dbb27b6e12c2be3fcbb3438dfd
4
+ data.tar.gz: 41147254b36a900c9bbdf85bf5b1f64345cd0d6e
5
5
  SHA512:
6
- metadata.gz: bb3429bee37af5438798de2c18f7aef16bca7508918054bb6afea0bddfb0641bf945477863f892ce9e4d3c9a6d26ac09d8d7a985d9c69e1115650e2231a243f2
7
- data.tar.gz: 39bbf742bc1420ddf751a14bf8ea66b42115b799d5682b60c5d7126c77c44eef70f92f144e8b690d26afc288189ce4883a93b09bc78d7bc6a5be522d422538fd
6
+ metadata.gz: 6ee3ed0cca9255e022e57548649f2464b1b08a29877e96b2e0187298b04c347b2caf3ea42739a3bffab34af6ac9081bed494feb875c7b9c583038f5ad69752a7
7
+ data.tar.gz: c2e67201fb0e76b5f2bd995bcbc6038c1948a27f5efdbeccb9f19b5eea0b4ae901d75f878265a9925daa3e3c4e5989d1a8fe2e5f59bff6853694080c3caa1169
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v 0.5.4
2
+ - Ensure that Instructions wrap a Hash with indifferent access
3
+ - Wire up both adapters for the PaginateProcessor
4
+ - Fix bug where ActiveRecord Paginator didn’t offset pages correctly
1
5
  v 0.5.3
2
6
  - Extract logic for creating new ActiveSet instance after an operation into separate method
3
7
  - Ensure that the instructions logged for the paginate operation handle defaults
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/hash/keys'
4
+ require 'active_support/core_ext/hash/indifferent_access'
4
5
 
5
6
  require_relative './entry'
6
7
 
@@ -9,7 +10,7 @@ class ActiveSet
9
10
  attr_reader :hash
10
11
 
11
12
  def initialize(hash)
12
- @hash = hash
13
+ @hash = hash.with_indifferent_access
13
14
  @flattened_hash = hash.flatten_keys.transform_keys { |k| k.map(&:to_s) }
14
15
  end
15
16
 
@@ -21,7 +21,7 @@ class ActiveSet
21
21
 
22
22
  def page_offset
23
23
  return 0 if page_number == 1
24
- page_size * page_number
24
+ page_size * (page_number - 1)
25
25
  end
26
26
 
27
27
  def page_size
@@ -6,17 +6,21 @@ require_relative './paginate/active_record_adapter'
6
6
 
7
7
  class ActiveSet
8
8
  class PaginateProcessor < BaseProcessor
9
+ queue_adapter ActiveRecordAdapter
10
+ queue_adapter EnumerableAdapter
11
+
9
12
  def process
10
- output = adapter.new(@set, instruction).process
11
- output[:set]
12
- end
13
+ adapters.each do |adapter|
14
+ output = adapter.new(@set, instruction).process
13
15
 
14
- private
16
+ return output[:set] if output[:processed]
17
+ end
15
18
 
16
- def adapter
17
- EnumerableAdapter
19
+ @set
18
20
  end
19
21
 
22
+ private
23
+
20
24
  def instruction
21
25
  Instructions::Entry.new(page_number, page_size)
22
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ActiveSet
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport