rasti-app 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48146c9e38f7981ffc3086c52a26cc867d3c7348
4
- data.tar.gz: 83c6c987d9045014ba3e47ea4e3ab789ee74e641
3
+ metadata.gz: 1a3d68bed67e69a49b6b61e8f0c7058c1f3e4927
4
+ data.tar.gz: 10e1c6c3e9f64c6616d7987359ea81bfc35bce16
5
5
  SHA512:
6
- metadata.gz: a8c7c6531d4cd4eae1784b4d04966ba66e0eb2859ac530cecde3d9039233af17d4b8a31aea03f02b628576c115c212c0f25813cb33debae4fe21c0631d6d02b2
7
- data.tar.gz: 36735b3619b895a576e57b5e92eeb3bd5f93fe9806f70059fefadda592b65c0d5d4a3daa778267586f0201c101d251292e9c3dab04bd0727cae9c29a0811ce5e
6
+ metadata.gz: 19a7db76e43ece80e16417fc0bffff50d0e50286eed9bf3c4ede22463d041bcdcb4c7a7f7de911b58a332d991a3f690c391c80e2cdb5de366130659a8d4996ec
7
+ data.tar.gz: 7bc3303502c93460d852747dd9edfeaf514c0a64951d0640dff2f7d5f733473b1c7507c250db7c6589814eb2536cbdd8ed7cba3c149197771e15d0c951f08a87
data/lib/rasti/app.rb CHANGED
@@ -61,17 +61,19 @@ module Rasti
61
61
  end
62
62
 
63
63
  def call(name, permission, params={})
64
- authorize! permission, params
65
- self.class.facade.call name, container, context, params
64
+ form = self.class.facade.build_form name, params
65
+ authorize! permission, form
66
+ self.class.facade.call name, container, context, form
66
67
  end
67
68
 
68
69
  def enqueue(name, permission, params={})
69
- authorize! permission, params
70
- self.class.facade.enqueue name, context, params
70
+ form = self.class.facade.build_form name, params
71
+ authorize! permission, form
72
+ self.class.facade.enqueue name, context, form
71
73
  end
72
74
 
73
- def authorize!(permission, params)
74
- policy.authorize! permission, params
75
+ def authorize!(permission, form)
76
+ policy.authorize! permission, form
75
77
  end
76
78
 
77
79
  end
@@ -12,14 +12,14 @@ module Rasti
12
12
  @job ||= Asynchronic[context.fetch(:job_id)].job
13
13
  end
14
14
 
15
- def enqueue(interaction, params)
15
+ def enqueue(interaction, form)
16
16
  job.send :async, Job, queue: params.delete(:queue) || Asynchronic.default_queue,
17
17
  alias: params.delete(:alias) || interaction,
18
18
  dependency: params.delete(:dependency),
19
19
  dependencies: params.delete(:dependencies),
20
20
  interaction: interaction,
21
21
  context: context,
22
- params: params
22
+ params: form.attributes
23
23
  end
24
24
 
25
25
  def result_of(reference)
@@ -55,8 +55,9 @@ module Rasti
55
55
  facade.synchronic_interactions.keys
56
56
  end
57
57
 
58
- def call_delegated_method(method_name, *args, &block)
59
- facade.call method_name, container, context, *args
58
+ def call_delegated_method(interaction_name, params={})
59
+ form = facade.build_form interaction_name, params
60
+ facade.call interaction_name, container, context, form
60
61
  end
61
62
 
62
63
  end
@@ -71,18 +72,22 @@ module Rasti
71
72
  end
72
73
  end
73
74
 
74
- def call(name, container, context, params={})
75
- interaction_class(name).new(container, context).call(params)
75
+ def build_form(name, params={})
76
+ interaction_class(name).build_form params
76
77
  end
77
78
 
78
- def enqueue(name, context, params={})
79
+ def call(name, container, context, form)
80
+ interaction_class(name).new(container, context).call(form)
81
+ end
82
+
83
+ def enqueue(name, context, form)
79
84
  interaction = interaction_class name
80
85
 
81
86
  Job.enqueue queue: params.delete(:queue) || Asynchronic.default_queue,
82
87
  alias: interaction,
83
88
  interaction: interaction,
84
89
  context: context,
85
- params: interaction.build_form(params).attributes
90
+ params: form.attributes
86
91
  end
87
92
 
88
93
  def synchronic_interactions
@@ -17,8 +17,8 @@ module Rasti
17
17
  @context = context
18
18
  end
19
19
 
20
- def call(params)
21
- thread_cache[:form] = self.class.build_form(params)
20
+ def call(form)
21
+ thread_cache[:form] = form
22
22
  validate!
23
23
  execute
24
24
  ensure
@@ -40,16 +40,16 @@ module Rasti
40
40
  @context = context
41
41
  end
42
42
 
43
- def authorized?(permission, params={})
43
+ def authorized?(permission, form)
44
44
  if self.class.authorizations.key? permission
45
- instance_exec params, &self.class.authorizations[permission]
45
+ instance_exec form, &self.class.authorizations[permission]
46
46
  else
47
47
  user.authorized? permission
48
48
  end
49
49
  end
50
50
 
51
- def authorize!(permission, params={})
52
- raise UnauthorizedError.new(user.name, permission) unless authorized? permission, params
51
+ def authorize!(permission, form)
52
+ raise UnauthorizedError.new(user.name, permission) unless authorized? permission, form
53
53
  end
54
54
 
55
55
  private
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  class App
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-17 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inflecto