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
- NGY2OTE5ZTU3YzNiYzVhNDNmZWFjZjBjNGE3NWVkMTUxNGE4ZjllNg==
4
+ MjlkODUyNGRkMjM2ZWE0ZDY1OGJjZTQ3ZjY5M2JhZDhjZGM5ZjQ1NQ==
5
5
  data.tar.gz: !binary |-
6
- NWEyMmQ0NjMxZjM0NWY4Y2U0NjRkNGVlZjQ2ZGMzOThlOTA3M2E1YQ==
6
+ NTE4Y2U4NzhhZDQ0NmNmZjBlYzY1NDk0OWU0MmIwMDczMzAzNjI3NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWVhOWY4NjY3OWM2NzhmOGNhOGJhYTEwZTU5YjU4ZDI2ODk2M2UwOWQ2MDM1
10
- ZDIwMWVlNmQ1MjMzOWZiZmRmNTNjYWM4NmU0YTI3NmVlM2ZlMTE5ODFiNjRm
11
- OTQ1YTQ5YmE1MTg2NGRmMDUxMTk4ZTdiZDZkYjVlMzBiN2Y4YzQ=
9
+ MmNjOWFlNTdmYzg0OWJiYTY3MWRjNWJiMjQyOWUyYmY0OTUzZmRhNDEzMjBh
10
+ NzdkNjMyYjE5ZTk1MjhlZGYzZGVmYmRlMWE0MDU0M2Y2MTRmZTQ2ZDVhMDEz
11
+ OGIzODUyZjA2YWEwZDMyMDRhMmZkN2JiNzVjYjUwZGRjYThmNWI=
12
12
  data.tar.gz: !binary |-
13
- NzNhNmI0Zjc5NjZlZGY0N2YyZmMxNmRiYTRkZTk2N2Y3YTk2M2RhODRjYTFm
14
- ZjlmMjI5YWRhYmUwOWFjZGQ1YzIwNDBlNDRmMzU0YjNhM2M0MmZkOGEwZjEw
15
- ZTAzNjk5YmYwY2I0MjgwNTIyYjQ4MzU5MTZhZjRiN2E1YzE4MzI=
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
- instance_exec(scope, id, context, &block.destructure)
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 = arguments.length-1)
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
@@ -1,3 +1,3 @@
1
1
  module JSONAPIonify
2
- VERSION = "0.12.5"
2
+ VERSION = "0.12.7"
3
3
  end
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.5
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-21 00:00:00.000000000 Z
11
+ date: 2016-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport