embark-journey 0.1.8 → 0.2.1
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 +5 -5
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/journey.gemspec +4 -4
- data/lib/active_resource/associations.rb +33 -25
- data/lib/active_resource/associations/builder/belongs_to.rb +6 -5
- data/lib/active_resource/connection.rb +91 -82
- data/lib/journey/resource/enum_sets.rb +3 -3
- data/lib/journey/resource/enums.rb +1 -1
- data/lib/journey/version.rb +2 -2
- data/spec/models/journey/resource_spec.rb +1 -1
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fdd390f5c0ba1d101822dfa42c227cfc35aea62e5bc3b0596cebaa5c67da8f26
|
4
|
+
data.tar.gz: 926ab77625595fef4309ca4b1d8817e8502c430ddf0ccc86f3e74e61f7b46219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351db664db68e9111061fba8b3a6a8f1807e702266d8a2408d98263e3e8f85924f50cea8f79429d000f0480a9ad6e1a9393a96b79b154b2a9a13e8567b374bcb
|
7
|
+
data.tar.gz: 810ed2df9d4afec6f369f27f0d0caba2cfdeeae7ced25d23c490a38926d61b1ebe1e432b686f486d1a615937147b14705bbb810c09b178fed3f279b500579497
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.8
|
data/CHANGELOG.md
CHANGED
data/journey.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'active_attr', '~> 0.
|
22
|
-
spec.add_runtime_dependency 'activeresource', '~>
|
21
|
+
spec.add_runtime_dependency 'active_attr', '~> 0.15.3'
|
22
|
+
spec.add_runtime_dependency 'activeresource', '~> 5.1.1'
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler', '~>
|
25
|
-
spec.add_development_dependency 'rake', '
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.2.22'
|
25
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0.0.beta1'
|
27
27
|
spec.add_development_dependency 'factory_girl', '~> 4.3.0'
|
28
28
|
spec.add_development_dependency 'dotenv', '~> 0.9.0'
|
@@ -1,13 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module ActiveResource::Associations
|
3
4
|
module Builder
|
4
|
-
autoload :Association,
|
5
|
-
autoload :HasMany,
|
6
|
-
autoload :HasOne,
|
7
|
-
# autoload :BelongsTo,
|
5
|
+
autoload :Association, "active_resource/associations/builder/association"
|
6
|
+
autoload :HasMany, "active_resource/associations/builder/has_many"
|
7
|
+
autoload :HasOne, "active_resource/associations/builder/has_one"
|
8
|
+
# autoload :BelongsTo, "active_resource/associations/builder/belongs_to"
|
8
9
|
require_relative 'associations/builder/belongs_to'
|
9
10
|
end
|
10
11
|
|
12
|
+
attr_accessor :embeds
|
13
|
+
|
14
|
+
def defines_belongs_to_embed(reflection)
|
15
|
+
self.embeds ||= []
|
16
|
+
self.embeds << reflection.name.to_s
|
17
|
+
end
|
18
|
+
|
11
19
|
|
12
20
|
# Specifies a one-to-many association.
|
13
21
|
#
|
@@ -65,9 +73,9 @@ module ActiveResource::Associations
|
|
65
73
|
# Would resolve this author into the <tt>Myblog::Author</tt> class.
|
66
74
|
#
|
67
75
|
# If the response body does not contain an attribute matching the association name
|
68
|
-
# a request is sent to a
|
76
|
+
# a request is sent to a singleton path under the current resource.
|
69
77
|
# For example, if a Product class <tt>has_one :inventory</tt> calling <tt>Product#inventory</tt>
|
70
|
-
# will generate a request on /
|
78
|
+
# will generate a request on /products/:product_id/inventory.json.
|
71
79
|
#
|
72
80
|
def has_one(name, options = {})
|
73
81
|
Builder::HasOne.build(self, name, options)
|
@@ -89,15 +97,15 @@ module ActiveResource::Associations
|
|
89
97
|
#
|
90
98
|
# === Example
|
91
99
|
#
|
92
|
-
# A Comment class
|
100
|
+
# A Comment class declares <tt>belongs_to :post</tt>, which will add:
|
93
101
|
# * <tt>Comment#post</tt> (similar to <tt>Post.find(post_id)</tt>)
|
94
102
|
# The declaration can also include an options hash to specialize the behavior of the association.
|
95
103
|
#
|
96
104
|
# === Options
|
97
105
|
# [:class_name]
|
98
|
-
# Specify the class name for the association. Use it only if that name
|
106
|
+
# Specify the class name for the association. Use it only if that name can't be inferred from association name.
|
99
107
|
# So <tt>belongs_to :post</tt> will by default be linked to the Post class, but if the real class name is Article,
|
100
|
-
# you'll have to specify it with
|
108
|
+
# you'll have to specify it with this option.
|
101
109
|
# [:foreign_key]
|
102
110
|
# Specify the foreign key used for the association. By default this is guessed to be the name
|
103
111
|
# of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :post</tt>
|
@@ -112,12 +120,13 @@ module ActiveResource::Associations
|
|
112
120
|
# <tt>belongs_to :customer, :foreign_key => 'user_id'</tt>
|
113
121
|
# Creates a belongs_to association called customer which would be resolved by the foreign_key <tt>user_id</tt> instead of <tt>customer_id</tt>
|
114
122
|
#
|
115
|
-
def belongs_to(name, options={})
|
123
|
+
def belongs_to(name, options = {})
|
116
124
|
Builder::BelongsTo.build(self, name, options)
|
117
125
|
end
|
118
126
|
|
119
127
|
# Defines the belongs_to association finder method
|
120
|
-
def defines_belongs_to_finder_method(
|
128
|
+
def defines_belongs_to_finder_method(reflection)
|
129
|
+
method_name = reflection.name
|
121
130
|
ivar_name = :"@#{method_name}"
|
122
131
|
|
123
132
|
if method_defined?(method_name)
|
@@ -130,9 +139,9 @@ module ActiveResource::Associations
|
|
130
139
|
instance_variable_get(ivar_name)
|
131
140
|
elsif attributes.include?(method_name)
|
132
141
|
attributes[method_name]
|
133
|
-
elsif association_id = send(
|
142
|
+
elsif association_id = send(reflection.foreign_key)
|
134
143
|
return nil if association_id.blank?
|
135
|
-
instance_variable_set(ivar_name, (
|
144
|
+
instance_variable_set(ivar_name, (reflection.klass.find(association_id) rescue nil))
|
136
145
|
end
|
137
146
|
end
|
138
147
|
|
@@ -142,13 +151,8 @@ module ActiveResource::Associations
|
|
142
151
|
end
|
143
152
|
end
|
144
153
|
|
145
|
-
|
146
|
-
|
147
|
-
self.embeds ||= []
|
148
|
-
self.embeds << method_name.to_s
|
149
|
-
end
|
150
|
-
|
151
|
-
def defines_has_many_finder_method(method_name, association_model)
|
154
|
+
def defines_has_many_finder_method(reflection)
|
155
|
+
method_name = reflection.name
|
152
156
|
ivar_name = :"@#{method_name}"
|
153
157
|
|
154
158
|
define_method(method_name) do
|
@@ -156,14 +160,17 @@ module ActiveResource::Associations
|
|
156
160
|
instance_variable_get(ivar_name)
|
157
161
|
elsif attributes.include?(method_name)
|
158
162
|
attributes[method_name]
|
163
|
+
elsif !new_record?
|
164
|
+
instance_variable_set(ivar_name, reflection.klass.find(:all, params: { q: { :"#{self.class.element_name}_id" => self.id } }))
|
159
165
|
else
|
160
|
-
instance_variable_set(ivar_name,
|
166
|
+
instance_variable_set(ivar_name, self.class.collection_parser.new)
|
161
167
|
end
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
165
171
|
# Defines the has_one association
|
166
|
-
def defines_has_one_finder_method(
|
172
|
+
def defines_has_one_finder_method(reflection)
|
173
|
+
method_name = reflection.name
|
167
174
|
ivar_name = :"@#{method_name}"
|
168
175
|
|
169
176
|
define_method(method_name) do
|
@@ -171,10 +178,11 @@ module ActiveResource::Associations
|
|
171
178
|
instance_variable_get(ivar_name)
|
172
179
|
elsif attributes.include?(method_name)
|
173
180
|
attributes[method_name]
|
181
|
+
elsif reflection.klass.respond_to?(:singleton_name)
|
182
|
+
instance_variable_set(ivar_name, reflection.klass.find(params: { q: { :"#{self.class.element_name}_id" => self.id } }))
|
174
183
|
else
|
175
|
-
instance_variable_set(ivar_name,
|
184
|
+
instance_variable_set(ivar_name, reflection.klass.find(:one, from: "/#{self.class.collection_name}/#{self.id}/#{method_name}#{self.class.format_extension}"))
|
176
185
|
end
|
177
186
|
end
|
178
187
|
end
|
179
|
-
|
180
188
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveResource::Associations::Builder
|
2
4
|
class BelongsTo < Association
|
3
5
|
self.valid_options += [:foreign_key, :embed]
|
4
6
|
|
@@ -9,11 +11,10 @@ module ActiveResource::Associations::Builder
|
|
9
11
|
embed = options.delete(:embed)
|
10
12
|
|
11
13
|
reflection = model.create_reflection(self.class.macro, name, options)
|
12
|
-
model.defines_belongs_to_finder_method(reflection
|
13
|
-
|
14
|
-
model.defines_belongs_to_embed(reflection.name, reflection.klass, reflection.foreign_key) if embed
|
14
|
+
model.defines_belongs_to_finder_method(reflection)
|
15
|
+
model.defines_belongs_to_embed(reflection)
|
15
16
|
|
16
|
-
|
17
|
+
reflection
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -1,27 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/benchmark"
|
4
|
+
require "active_support/core_ext/uri"
|
5
|
+
require "active_support/core_ext/object/inclusion"
|
6
|
+
require "net/https"
|
7
|
+
require "date"
|
8
|
+
require "time"
|
9
|
+
require "uri"
|
8
10
|
|
9
11
|
module ActiveResource
|
10
12
|
# Class to handle connections to remote web services.
|
11
13
|
# This class is used by ActiveResource::Base to interface with REST
|
12
14
|
# services.
|
13
15
|
class Connection
|
14
|
-
|
15
|
-
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:head => 'Accept'
|
16
|
+
HTTP_FORMAT_HEADER_NAMES = { get: "Accept",
|
17
|
+
put: "Content-Type",
|
18
|
+
post: "Content-Type",
|
19
|
+
patch: "Content-Type",
|
20
|
+
delete: "Accept",
|
21
|
+
head: "Accept"
|
21
22
|
}
|
22
23
|
|
23
|
-
attr_reader :site, :user, :password, :auth_type, :timeout, :proxy, :ssl_options
|
24
|
-
attr_accessor :format
|
24
|
+
attr_reader :site, :user, :password, :bearer_token, :auth_type, :timeout, :open_timeout, :read_timeout, :proxy, :ssl_options
|
25
|
+
attr_accessor :format, :logger
|
25
26
|
|
26
27
|
class << self
|
27
28
|
def requests
|
@@ -31,11 +32,12 @@ module ActiveResource
|
|
31
32
|
|
32
33
|
# The +site+ parameter is required and will set the +site+
|
33
34
|
# attribute to the URI for the remote resource service.
|
34
|
-
def initialize(site, format = ActiveResource::Formats::JsonFormat)
|
35
|
-
raise ArgumentError,
|
36
|
-
@proxy = @user = @password = nil
|
35
|
+
def initialize(site, format = ActiveResource::Formats::JsonFormat, logger: nil)
|
36
|
+
raise ArgumentError, "Missing site URI" unless site
|
37
|
+
@proxy = @user = @password = @bearer_token = nil
|
37
38
|
self.site = site
|
38
39
|
self.format = format
|
40
|
+
self.logger = logger
|
39
41
|
end
|
40
42
|
|
41
43
|
# Set URI for remote service.
|
@@ -52,14 +54,13 @@ module ActiveResource
|
|
52
54
|
end
|
53
55
|
|
54
56
|
# Sets the user for remote service.
|
55
|
-
|
56
|
-
@user = user
|
57
|
-
end
|
57
|
+
attr_writer :user
|
58
58
|
|
59
59
|
# Sets the password for remote service.
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
attr_writer :password
|
61
|
+
|
62
|
+
# Sets the bearer token for remote service.
|
63
|
+
attr_writer :bearer_token
|
63
64
|
|
64
65
|
# Sets the auth type for remote service.
|
65
66
|
def auth_type=(auth_type)
|
@@ -67,14 +68,16 @@ module ActiveResource
|
|
67
68
|
end
|
68
69
|
|
69
70
|
# Sets the number of seconds after which HTTP requests to the remote service should time out.
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
attr_writer :timeout
|
72
|
+
|
73
|
+
# Sets the number of seconds after which HTTP connects to the remote service should time out.
|
74
|
+
attr_writer :open_timeout
|
75
|
+
|
76
|
+
# Sets the number of seconds after which HTTP read requests to the remote service should time out.
|
77
|
+
attr_writer :read_timeout
|
73
78
|
|
74
79
|
# Hash of options applied to Net::HTTP instance when +site+ protocol is 'https'.
|
75
|
-
|
76
|
-
@ssl_options = options
|
77
|
-
end
|
80
|
+
attr_writer :ssl_options
|
78
81
|
|
79
82
|
# Executes a GET request.
|
80
83
|
# Used to get (find) resources.
|
@@ -90,19 +93,19 @@ module ActiveResource
|
|
90
93
|
|
91
94
|
# Executes a PATCH request (see HTTP protocol documentation if unfamiliar).
|
92
95
|
# Used to update resources.
|
93
|
-
def patch(path, body =
|
96
|
+
def patch(path, body = "", headers = {})
|
94
97
|
with_auth { request(:patch, path, body.to_s, build_request_headers(headers, :patch, self.site.merge(path))) }
|
95
98
|
end
|
96
99
|
|
97
100
|
# Executes a PUT request (see HTTP protocol documentation if unfamiliar).
|
98
101
|
# Used to update resources.
|
99
|
-
def put(path, body =
|
102
|
+
def put(path, body = "", headers = {})
|
100
103
|
with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, self.site.merge(path))) }
|
101
104
|
end
|
102
105
|
|
103
106
|
# Executes a POST request.
|
104
107
|
# Used to create new resources.
|
105
|
-
def post(path, body =
|
108
|
+
def post(path, body = "", headers = {})
|
106
109
|
with_auth { request(:post, path, body.to_s, build_request_headers(headers, :post, self.site.merge(path))) }
|
107
110
|
end
|
108
111
|
|
@@ -129,6 +132,7 @@ module ActiveResource
|
|
129
132
|
|
130
133
|
# Handles response and error codes from the remote service.
|
131
134
|
def handle_response(response)
|
135
|
+
|
132
136
|
if response.respond_to?(:header) && (response.header["content-encoding"] == 'gzip')
|
133
137
|
begin
|
134
138
|
response.instance_variable_set('@body', ActiveSupport::Gzip.decompress(response.body))
|
@@ -137,34 +141,33 @@ module ActiveResource
|
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
140
|
-
|
141
144
|
case response.code.to_i
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
145
|
+
when 301, 302, 303, 307
|
146
|
+
raise(Redirection.new(response))
|
147
|
+
when 200...400
|
148
|
+
response
|
149
|
+
when 400
|
150
|
+
raise(BadRequest.new(response))
|
151
|
+
when 401
|
152
|
+
raise(UnauthorizedAccess.new(response))
|
153
|
+
when 403
|
154
|
+
raise(ForbiddenAccess.new(response))
|
155
|
+
when 404
|
156
|
+
raise(ResourceNotFound.new(response))
|
157
|
+
when 405
|
158
|
+
raise(MethodNotAllowed.new(response))
|
159
|
+
when 409
|
160
|
+
raise(ResourceConflict.new(response))
|
161
|
+
when 410
|
162
|
+
raise(ResourceGone.new(response))
|
163
|
+
when 422
|
164
|
+
raise(ResourceInvalid.new(response))
|
165
|
+
when 401...500
|
166
|
+
raise(ClientError.new(response))
|
167
|
+
when 500...600
|
168
|
+
raise(ServerError.new(response))
|
169
|
+
else
|
170
|
+
raise(ConnectionError.new(response, "Unknown response code: #{response.code}"))
|
168
171
|
end
|
169
172
|
end
|
170
173
|
|
@@ -176,7 +179,9 @@ module ActiveResource
|
|
176
179
|
|
177
180
|
def new_http
|
178
181
|
if @proxy
|
179
|
-
|
182
|
+
user = URI.parser.unescape(@proxy.user) if @proxy.user
|
183
|
+
password = URI.parser.unescape(@proxy.password) if @proxy.password
|
184
|
+
Net::HTTP.new(@site.host, @site.port, @proxy.host, @proxy.port, user, password)
|
180
185
|
else
|
181
186
|
Net::HTTP.new(@site.host, @site.port)
|
182
187
|
end
|
@@ -189,6 +194,8 @@ module ActiveResource
|
|
189
194
|
https.open_timeout = @timeout
|
190
195
|
https.read_timeout = @timeout
|
191
196
|
end
|
197
|
+
https.open_timeout = @open_timeout if defined?(@open_timeout)
|
198
|
+
https.read_timeout = @read_timeout if defined?(@read_timeout)
|
192
199
|
end
|
193
200
|
end
|
194
201
|
|
@@ -198,9 +205,6 @@ module ActiveResource
|
|
198
205
|
if defined? @ssl_options
|
199
206
|
http.use_ssl = true
|
200
207
|
|
201
|
-
# Default to no cert verification (WTF? FIXME)
|
202
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
203
|
-
|
204
208
|
# All the SSL options have corresponding http settings.
|
205
209
|
@ssl_options.each { |key, value| http.send "#{key}=", value }
|
206
210
|
end
|
@@ -225,7 +229,7 @@ module ActiveResource
|
|
225
229
|
yield
|
226
230
|
rescue UnauthorizedAccess => e
|
227
231
|
raise if retried || auth_type != :digest
|
228
|
-
@response_auth_header = e.response[
|
232
|
+
@response_auth_header = e.response["WWW-Authenticate"]
|
229
233
|
retried = true
|
230
234
|
retry
|
231
235
|
end
|
@@ -233,10 +237,12 @@ module ActiveResource
|
|
233
237
|
def authorization_header(http_method, uri)
|
234
238
|
if @user || @password
|
235
239
|
if auth_type == :digest
|
236
|
-
{
|
240
|
+
{ "Authorization" => digest_auth_header(http_method, uri) }
|
237
241
|
else
|
238
|
-
{
|
242
|
+
{ "Authorization" => "Basic " + ["#{@user}:#{@password}"].pack("m").delete("\r\n") }
|
239
243
|
end
|
244
|
+
elsif @bearer_token
|
245
|
+
{ "Authorization" => "Bearer #{@bearer_token}" }
|
240
246
|
else
|
241
247
|
{}
|
242
248
|
end
|
@@ -251,8 +257,8 @@ module ActiveResource
|
|
251
257
|
ha1 = Digest::MD5.hexdigest("#{@user}:#{params['realm']}:#{@password}")
|
252
258
|
ha2 = Digest::MD5.hexdigest("#{http_method.to_s.upcase}:#{request_uri}")
|
253
259
|
|
254
|
-
params
|
255
|
-
request_digest = Digest::MD5.hexdigest([ha1, params[
|
260
|
+
params["cnonce"] = client_nonce
|
261
|
+
request_digest = Digest::MD5.hexdigest([ha1, params["nonce"], "0", params["cnonce"], params["qop"], ha2].join(":"))
|
256
262
|
"Digest #{auth_attributes_for(uri, request_digest, params)}"
|
257
263
|
end
|
258
264
|
|
@@ -269,26 +275,29 @@ module ActiveResource
|
|
269
275
|
end
|
270
276
|
|
271
277
|
def auth_attributes_for(uri, request_digest, params)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
278
|
+
auth_attrs =
|
279
|
+
[
|
280
|
+
%Q(username="#{@user}"),
|
281
|
+
%Q(realm="#{params['realm']}"),
|
282
|
+
%Q(qop="#{params['qop']}"),
|
283
|
+
%Q(uri="#{uri.path}"),
|
284
|
+
%Q(nonce="#{params['nonce']}"),
|
285
|
+
'nc="0"',
|
286
|
+
%Q(cnonce="#{params['cnonce']}"),
|
287
|
+
%Q(response="#{request_digest}")]
|
288
|
+
|
289
|
+
auth_attrs << %Q(opaque="#{params['opaque']}") unless params["opaque"].blank?
|
290
|
+
auth_attrs.join(", ")
|
282
291
|
end
|
283
292
|
|
284
293
|
def http_format_header(http_method)
|
285
|
-
{HTTP_FORMAT_HEADER_NAMES[http_method] => format.mime_type}
|
294
|
+
{ HTTP_FORMAT_HEADER_NAMES[http_method] => format.mime_type }
|
286
295
|
end
|
287
296
|
|
288
297
|
def legitimize_auth_type(auth_type)
|
289
298
|
return :basic if auth_type.nil?
|
290
299
|
auth_type = auth_type.to_sym
|
291
|
-
auth_type.in?([:basic, :digest]) ? auth_type : :basic
|
300
|
+
auth_type.in?([:basic, :digest, :bearer]) ? auth_type : :basic
|
292
301
|
end
|
293
302
|
end
|
294
303
|
end
|
@@ -17,7 +17,7 @@ module Journey::Resource::EnumSets
|
|
17
17
|
define_method attr do
|
18
18
|
arr = attributes[attr.to_s].presence || []
|
19
19
|
arr.map do |member|
|
20
|
-
if member.is_a?(
|
20
|
+
if member.is_a?(Integer)
|
21
21
|
self.class.const_get(collection_const_name)[member]
|
22
22
|
else
|
23
23
|
member
|
@@ -27,7 +27,7 @@ module Journey::Resource::EnumSets
|
|
27
27
|
|
28
28
|
define_method "#{attr}=" do |value|
|
29
29
|
attributes[attr.to_s] = value.map do |member|
|
30
|
-
if member.is_a?(
|
30
|
+
if member.is_a?(Integer)
|
31
31
|
member
|
32
32
|
else
|
33
33
|
self.class.const_get(collection_const_name).index(member)
|
@@ -38,7 +38,7 @@ module Journey::Resource::EnumSets
|
|
38
38
|
define_method "add_#{attr}" do |value|
|
39
39
|
attr_values = send("#{attr}_values")
|
40
40
|
|
41
|
-
value_index = if value.is_a?(
|
41
|
+
value_index = if value.is_a?(Integer)
|
42
42
|
value
|
43
43
|
else
|
44
44
|
attr_values.index(value)
|
data/lib/journey/version.rb
CHANGED
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.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Davey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.15.3
|
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: 0.15.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activeresource
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.1.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.1.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.2.22
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.2.22
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
|
-
|
195
|
-
rubygems_version: 2.2.2
|
194
|
+
rubygems_version: 3.0.3.1
|
196
195
|
signing_key:
|
197
196
|
specification_version: 4
|
198
197
|
summary: Journey API wrapper for Ruby
|