activeset 0.8.2 → 0.8.3

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
  SHA1:
3
- metadata.gz: '090c118d248ba30a9211b369e12636499c05a95b'
4
- data.tar.gz: 458586ba5bfcddaedaf6fab6ebaf09f8d36a6e14
3
+ metadata.gz: 0a35c45c1515b720f53f45bbaf0f56a3de6b36af
4
+ data.tar.gz: 65588202096e28453bd828643884b51489aa5f4a
5
5
  SHA512:
6
- metadata.gz: 33676ed9e211c8fa8c70048851815d52931ba4b11ed6e3704180ee25629fd322dac291d72223c24757699698ae07726bb7f26b3d4a9c08bad62149009b845a62
7
- data.tar.gz: 8db447ae3d2440bca54cb0a47c4d2f8c1ae93794087228ed702e7bffdd03aeaa60f09fd9431f7149cd1913cf959c572b9ac1bbee50be207c4afb491d6cb21713
6
+ metadata.gz: 691731355d82e7fd51af5b76ce8caffe3e54f4decef98986595f67b8916c043ae52cdf3fbbd694d568844302d2f609988befa62df5e6720e1b808111a59f93a7
7
+ data.tar.gz: 2c66f5a2d7ae05fbeebf0267ac36736f6ab42c0e42d9f70189af65b03f429ae88de4159489b7725c6f89a677c760230a7f14b9db518c287402f57f9220f38490
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v 0.8.3
2
+ - fix a bug to allow sorting of computed attributes on sets that include nil values
1
3
  v 0.8.2
2
4
  - fix a bug that prevents enumerable sets from being filtered down to empty sets
3
5
  v 0.8.1
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  Gem::Specification.new do |spec|
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.name = 'activeset'
9
- spec.version = '0.8.2'
9
+ spec.version = '0.8.3'
10
10
  spec.authors = ['Stephen Margheim']
11
11
  spec.email = ['stephen.margheim@gmail.com']
12
12
 
@@ -14,7 +14,19 @@ class ActiveSet
14
14
  # http://brandon.dimcheff.com/2009/11/18/rubys-sort-vs-sort-by/
15
15
  @set.sort_by do |item|
16
16
  @attribute_instructions.map do |instruction|
17
- sortable_numeric_for(instruction, item) * direction_multiplier(instruction.value)
17
+ value_for_comparison = sortable_numeric_for(instruction, item)
18
+ direction_multiplier = direction_multiplier(instruction.value)
19
+
20
+ # in an ASC sort, nils float to the end of the list. In a DESC
21
+ # sort, nils float to the start of the list. This is achieved by
22
+ # wrapping each value_for_comparison in a tuple with 0 as the first
23
+ # element, and wrapping nil values with either 1 or -1 as the first
24
+ # element
25
+ if value_for_comparison.nil?
26
+ [direction_multiplier, 0]
27
+ else
28
+ [0, value_for_comparison * direction_multiplier]
29
+ end
18
30
  end
19
31
  end
20
32
  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.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport