embark-journey 0.0.14 → 0.0.15

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: b4e7a47883c9d0a23ab06dd8690f8a2ad9cf9811
4
- data.tar.gz: 550ccd3b424608792f87daa3b7277a828a443005
3
+ metadata.gz: 2b77138254b5e0798166326dbc1c358ef737030d
4
+ data.tar.gz: 004fb01ba67f78d0ff4a105c42c7e74f945fb048
5
5
  SHA512:
6
- metadata.gz: 40df328dcace9a9d751fd69e01062cc295586be55a1c1efd2a6d30f4c4d27cfa3c4cec44820cb89b685ab7051c1a62e0354e53324de9930462e1fb146e93ad33
7
- data.tar.gz: 4abe2a0b4861a465a841309eba0c073886a8b38af9b3fcccf28befb845bc009848d98a325c9e8cbe8efb6c8b2675b3ef54cd8c25f3deaa3d51b87722f5d0fc6a
6
+ metadata.gz: 1c716e4eaa31dc97d3e7fb4580279d1e51dea714e4ba7d1f670d34e52e7d55b8f9f693d902c91123f06ba7a7dccba192eb7ddf8c35b222d51cf090787c981e55
7
+ data.tar.gz: 44ab1288bc9095847d84438a16a4bff6c182df9e3eacad06cef241423c6d99c58212b33cf8dcc1b83082f5466ad9db8b2f12e6cf37f5aa2a3acac73a20e6896c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ v0.0.15
2
+ - added compatibility around enum_sets from Journey (using indices rather than text values)
3
+
1
4
  v0.0.14
2
5
  - some sugar around enum_sets
3
6
 
@@ -12,16 +12,29 @@ module Journey::Resource::EnumSets
12
12
  end
13
13
 
14
14
  define_method attr do
15
- value = attributes[attr.to_s].presence
16
- value.presence || []
15
+ arr = attributes[attr.to_s].presence || []
16
+ arr.map do |member|
17
+ if member.is_a?(Fixnum)
18
+ self.class.const_get(collection_const_name)[member]
19
+ else
20
+ member
21
+ end
22
+ end
17
23
  end
18
24
 
19
25
  define_method "add_#{attr}" do |value|
20
- new_value = value.presence
21
- if send("#{attr}_values").include? new_value
22
- (attributes[attr.to_s] ||= []) << new_value
26
+ attr_values = send("#{attr}_values")
27
+
28
+ value_index = if value.is_a?(Fixnum)
29
+ value
30
+ else
31
+ attr_values.index(value)
32
+ end
33
+
34
+ if (0..attr_values.size-1).include? value_index
35
+ (attributes[attr.to_s] ||= []) << value_index
23
36
  else
24
- raise "Invalid enum '#{new_value}' for '#{attr}'"
37
+ raise "Invalid enum '#{value}' for '#{attr}'"
25
38
  end
26
39
  end
27
40
  end
@@ -14,7 +14,7 @@ module Journey::Resource::Enums
14
14
  instance_eval do
15
15
  attr_accessor :"#{attr}_index"
16
16
  end
17
-
17
+
18
18
  define_method attr do
19
19
  value = attributes[attr.to_s].presence
20
20
  if value.is_a?(Fixnum)
@@ -23,7 +23,7 @@ module Journey::Resource::Enums
23
23
  value
24
24
  end
25
25
  end
26
-
26
+
27
27
  define_method "#{attr}=" do |value|
28
28
  attributes[attr.to_s] = value.presence
29
29
  end
@@ -2,7 +2,7 @@ module Journey
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 14
5
+ TINY = 15
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
8
  end
@@ -96,6 +96,11 @@ describe Journey::Resource do
96
96
  expect(r.asset_type).to eq []
97
97
  end
98
98
 
99
+ it 'converts integer indices to corresponding keys' do
100
+ r = klass.create(name: 'X', asset_type: [0])
101
+ expect(r.asset_type).to eq [klass::ASSET_TYPES.first]
102
+ end
103
+
99
104
  it 'safely adds members' do
100
105
  r = klass.create(name: 'X', asset_type: nil)
101
106
  r = klass.find(r.id)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embark-journey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr