activerpc 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10ba3417ba62f8c6113543c46d4fc9f869a85c18a7fdc91160fc9a918043dc64
4
- data.tar.gz: d59077929216fca8f7ab8067cfe643d7c72fdeca5f0aa359db955bd932a098d6
3
+ metadata.gz: 731fbeef55a0b7a9bacbf22b09caabd6599f66032ac24e34d834889f7c810ef3
4
+ data.tar.gz: 841090dce51a1285eb0f2e63e17c3f5f6c868c211caef620f7a91e2991bf267b
5
5
  SHA512:
6
- metadata.gz: 2abecebe8eea82db866c8e51789956fde73c34af67a51355e7c919b66259bd3e8eb036b920b4749f8e30c857f057aaad646d72956db9b2c1f987293c15204d51
7
- data.tar.gz: 1a77d1a284b54598eab87f67c2bca9007946b059edbd47a94362c0691b2586a7769b74b6283ef5007541454d5269b8a2e644d52d6f6ebc6dfab75cbcb4b6e1a1
6
+ metadata.gz: 9c30c2aa2c713da842b21d1ce591ed350856f27bad5c154f1a60b1bfa223c4e4bd4d32ec25f2de30e9a21dcd1d52e9d05b6368dc4161f42e47185ee444c8fdbe
7
+ data.tar.gz: 0fdc8cc5a86773f43835223976941e90e8222c86191bb18110380e18f0fe3a83ec594e29d6c99024a4da13f9d511e447ef2422e56a037e3ef5928cdf12fe4a54
data/README.md CHANGED
@@ -12,7 +12,7 @@ using standard Rails tools and toolchains.
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'activerpc'
15
+ gem 'activerpc', '~> 0.1'
16
16
  ```
17
17
 
18
18
  And then execute:
@@ -35,6 +35,8 @@ end
35
35
  ```
36
36
 
37
37
  ## Usage
38
+
39
+ #### Operations
38
40
  The JSONRPC spec supports two kinds of parameters being passed to a method. We
39
41
  feel strongly that only the Hash/Object form should be used rather than the
40
42
  Array/positional form. The reason for this is that it is significantly less
@@ -55,6 +57,10 @@ class MyRpcMethod < ActiveRpc::Operation
55
57
  def call
56
58
  "Hello #{name}, you are #{age} years old."
57
59
  end
60
+
61
+ before_validation do
62
+ # do something to check on the inputs before validating them
63
+ end
58
64
  end
59
65
  ```
60
66
 
@@ -73,6 +79,25 @@ def call
73
79
  end
74
80
  ```
75
81
 
82
+ #### Controller Lifecycle Events
83
+ You can provide `around`, `before` or `after` hooks to tie into the controller
84
+ lifecycle, whether for authentication, authorization or whatever else.
85
+
86
+ To provide a hook, you need to pass something that responds to the corresponding
87
+ method to the appropriate setting in the config, e.g.
88
+
89
+ ```ruby
90
+ ActiveRpc.configure do |config|
91
+ config.around_action = Module.new do
92
+ def self.around(controller) # method name matches the hook type
93
+ puts controller.request.remote_ip
94
+ yield
95
+ end
96
+ end
97
+ end
98
+ ```
99
+
100
+ #### Development Mode
76
101
  Please note, in development mode you might have issues with the operation classes
77
102
  being autoloaded. The new bootloader in Rails 6 will solve this, but until then you
78
103
  can add something similar to the below to an initialiser.
@@ -1,8 +1,14 @@
1
1
  module ActiveRpc
2
2
  class RpcController < ActionController::Base
3
- after_action ActiveRpc.config.after_action
4
- around_action ActiveRpc.config.around_action
5
- before_action ActiveRpc.config.before_action
3
+ if ActiveRpc.config.after_action.present?
4
+ after_action ActiveRpc.config.after_action
5
+ end
6
+ if ActiveRpc.config.around_action.present?
7
+ around_action ActiveRpc.config.around_action
8
+ end
9
+ if ActiveRpc.config.before_action.present?
10
+ before_action ActiveRpc.config.before_action
11
+ end
6
12
 
7
13
  def create
8
14
  res = nil
@@ -1,3 +1,3 @@
1
1
  module ActiveRpc
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Maxwell