jsonapionify 0.12.5 → 0.12.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjlkODUyNGRkMjM2ZWE0ZDY1OGJjZTQ3ZjY5M2JhZDhjZGM5ZjQ1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTE4Y2U4NzhhZDQ0NmNmZjBlYzY1NDk0OWU0MmIwMDczMzAzNjI3NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmNjOWFlNTdmYzg0OWJiYTY3MWRjNWJiMjQyOWUyYmY0OTUzZmRhNDEzMjBh
|
10
|
+
NzdkNjMyYjE5ZTk1MjhlZGYzZGVmYmRlMWE0MDU0M2Y2MTRmZTQ2ZDVhMDEz
|
11
|
+
OGIzODUyZjA2YWEwZDMyMDRhMmZkN2JiNzVjYjUwZGRjYThmNWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2UxMDM5NTBjNzE2N2FkYTBhOTE2MjhlNzY3M2ZiOTcwZjM0YjUwYzMxNWM1
|
14
|
+
YTAyZWNiZjMzZTAzMTM0NDU4Yjg0YzIxMTc5Nzc1MzlmZmI0NzZhYzNhZjdj
|
15
|
+
NzUxOGI0ZjQwYzZiMTQ5NTFiMzkyZWE4ZmY1YzlhMzQwZGM2OGQ=
|
@@ -15,16 +15,17 @@ module JSONAPIonify::Api
|
|
15
15
|
|
16
16
|
def instance(&block)
|
17
17
|
define_singleton_method(:find_instance) do |id|
|
18
|
-
instance_exec(current_scope, id, OpenStruct.new, &block.destructure)
|
18
|
+
instance_exec(current_scope, id, OpenStruct.new, &block.destructure(object: OpenStruct.new))
|
19
19
|
end
|
20
20
|
context :instance, persisted: true do |context, scope:, id:|
|
21
|
-
|
21
|
+
$pry = true
|
22
|
+
instance_exec(scope, id, context, &block.destructure(object: context))
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
def collection(&block)
|
26
27
|
context :collection do |context, scope:, includes:|
|
27
|
-
collection = instance_exec(scope, context, &block.destructure)
|
28
|
+
collection = instance_exec(scope, context, &block.destructure(object: context))
|
28
29
|
|
29
30
|
# Compute includes manipulations
|
30
31
|
self.class.include_definitions.select do |relationship, _|
|
@@ -41,10 +42,10 @@ module JSONAPIonify::Api
|
|
41
42
|
|
42
43
|
def new_instance(&block)
|
43
44
|
define_singleton_method(:build_instance) do
|
44
|
-
Object.new.instance_exec(current_scope, &block.destructure)
|
45
|
+
Object.new.instance_exec(current_scope, &block.destructure(object: OpenStruct.new))
|
45
46
|
end
|
46
47
|
context :new_instance, persisted: true, readonly: true do |context, scope:|
|
47
|
-
Object.new.instance_exec(scope, context, &block.destructure)
|
48
|
+
Object.new.instance_exec(scope, context, &block.destructure(object: context))
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module JSONAPIonify::DestructuredProc
|
2
2
|
refine Proc do
|
3
|
-
def destructure(at_index =
|
3
|
+
def destructure(at_index = -1, object: nil)
|
4
4
|
return self unless kwargs.present?
|
5
5
|
original = self
|
6
6
|
Proc.new do |*args|
|
7
|
-
kwargs = original.kwargs_destructured(args[at_index])
|
7
|
+
kwargs = original.kwargs_destructured(object || args[at_index])
|
8
8
|
JSONAPIonify::CustomRescue.perform(remove: __FILE__, source: original, formatter: ->(meta) { meta.source_location.join(':') + ":in `block (destructured)'" }) do
|
9
9
|
instance_exec(*args, **kwargs, &original)
|
10
10
|
end
|
data/lib/jsonapionify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapionify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Waldrip
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|