embark-journey 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/lib/journey/resource/attribute_loading.rb +11 -2
- data/lib/journey/resource/enum_sets.rb +15 -2
- data/lib/journey/resource/search.rb +1 -1
- data/lib/journey/version.rb +1 -1
- data/spec/models/journey/resource_spec.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3998c199ed52d9b9c1c18b8a232a3448588b039
|
4
|
+
data.tar.gz: 837e0d85bf8f77bc7dac887f43143ff38580ef8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50afca97c3f70db7b65c98599441f5c7566e051511a39771228dde204e3c26b08ddb82bea5dc852a75a17e9069597a5a7b0d9c6fd4b2eecd438b4aa708d5ab5e
|
7
|
+
data.tar.gz: 77efa8e28f9da152bdcccea89fd400df1cd15f1f1687901aa7528cd6c67cafe7e77f5c1b3d1b9415fbfa0e167b640c1f1df743bc158c683c888b960d58a51670
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--format
|
2
|
+
--format documentation
|
@@ -7,9 +7,18 @@ module Journey::Resource::AttributeLoading
|
|
7
7
|
def load(attributes, remove_root = false, persisted = false)
|
8
8
|
# 'data' is a reserved key in ActiveResource,
|
9
9
|
# but Journey uses it for the Oplog
|
10
|
-
|
11
10
|
attributes['content'] = attributes.delete('data')
|
12
|
-
|
11
|
+
|
12
|
+
super(attributes, remove_root, persisted).tap do
|
13
|
+
|
14
|
+
# allow enum_sets to be loaded by key (rather than index)
|
15
|
+
# by auto-converting them on initialization
|
16
|
+
if enum_sets = self.class.instance_variable_get(:@enum_sets)
|
17
|
+
enum_sets.each do |enum_attr|
|
18
|
+
send("#{enum_attr}=", send(enum_attr))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
|
@@ -5,8 +5,11 @@ module Journey::Resource::EnumSets
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
def self.enum_set(attr, collection=[])
|
8
|
+
(@enum_sets ||= []) << attr
|
9
|
+
|
8
10
|
collection_const_name = attr.to_s.pluralize.upcase.to_sym
|
9
|
-
const_set collection_const_name, collection.freeze
|
11
|
+
const_set collection_const_name, collection.freeze
|
12
|
+
|
10
13
|
define_method "#{attr}_values" do
|
11
14
|
self.class.const_get(collection_const_name)
|
12
15
|
end
|
@@ -22,6 +25,16 @@ module Journey::Resource::EnumSets
|
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
28
|
+
define_method "#{attr}=" do |value|
|
29
|
+
attributes[attr.to_s] = value.map do |member|
|
30
|
+
if member.is_a?(Fixnum)
|
31
|
+
member
|
32
|
+
else
|
33
|
+
self.class.const_get(collection_const_name).index(member)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
define_method "add_#{attr}" do |value|
|
26
39
|
attr_values = send("#{attr}_values")
|
27
40
|
|
@@ -34,7 +47,7 @@ module Journey::Resource::EnumSets
|
|
34
47
|
if (0..attr_values.size-1).include? value_index
|
35
48
|
(attributes[attr.to_s] ||= []) << value_index
|
36
49
|
else
|
37
|
-
raise "Invalid
|
50
|
+
raise "Invalid enum_set value: '#{value}' for '#{attr}'"
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
data/lib/journey/version.rb
CHANGED
@@ -80,15 +80,16 @@ describe Journey::Resource do
|
|
80
80
|
r = klass.create(name: 'X')
|
81
81
|
expect(r).to be_persisted
|
82
82
|
r.asset_type = ['ATM']
|
83
|
-
r.save
|
83
|
+
expect(r.save).to be true
|
84
|
+
|
84
85
|
r = klass.find(r.id)
|
85
|
-
expect(r.asset_type).to eq
|
86
|
+
expect(r.asset_type).to eq ['ATM']
|
86
87
|
end
|
87
88
|
|
88
|
-
it 'remembers
|
89
|
-
r = klass.create(name: 'X', asset_type: ['
|
89
|
+
it 'remembers enum_set values' do
|
90
|
+
r = klass.create(name: 'X', asset_type: ['ABM', 'ATM'])
|
90
91
|
r = klass.find(r.id)
|
91
|
-
expect(r.asset_type).to eq ['
|
92
|
+
expect(r.asset_type).to eq ['ABM', 'ATM']
|
92
93
|
end
|
93
94
|
|
94
95
|
it 'defaults to empty array' do
|
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.
|
4
|
+
version: 0.0.18
|
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-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|