nayati 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -7
- data/lib/nayati/version.rb +1 -1
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5895a775d5ab307538361d102345d8a51fe586c4
|
4
|
+
data.tar.gz: c5dff7d34b4608012be012f75227fb692601f1cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3390ec057e216347fc95e771ae7150a1432cf2e7a3aecfe42135f23320e123cbccc65d47cfc6fbbf014879563cb17b52d20dcb70fc4ec70a8bfe4456a07b70d4
|
7
|
+
data.tar.gz: bef30cec145ec40a6537af10674a0befaa86402106ed6a38bcd5ef7db1884addc0d819788a6a8f0c12562b64fbf59902a92e73c13d0fecfe306c4158403cfce2
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Nayati
|
2
|
-
Nayati is a Rails engine that helps in creating a clean and maintainable multi tenant Rails application. Creating multitenant application with Nayati allows you to have models that do just database talking and business logic gets handled by a layer I like to call 'Operation layer'. The sequence in which these operations get executed for a tenant is put in database.
|
2
|
+
Nayati is a Rails engine that helps in creating a clean and maintainable multi tenant Rails application. Creating multitenant application with Nayati allows you to have models that do just database talking and don't hold much business logic. Business logic gets handled by a layer I like to call 'Operation layer'. The sequence in which these operations get executed for a tenant is put in database.
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
Add this line to your application's Gemfile:
|
@@ -21,12 +21,14 @@ First run the install generator
|
|
21
21
|
```bash
|
22
22
|
$ rails generator nayati:install
|
23
23
|
```
|
24
|
+
## How an app is structured using nayati
|
25
|
+
|
26
|
+
![Image of nayati structure](https://github.com/tanmayforgit/nayati/blob/master/Nayati%20structure.png)
|
24
27
|
|
25
28
|
## How to use
|
26
29
|
Nayati is meant to help in handling functional changes across tenants in your application.
|
27
30
|
Lets say you have a attendance system. Your company installs devices which have fingerprint scanning functionality. Your clients vary from
|
28
|
-
scools, gym, private companies. Now lets say you have 5 'operations' that can happen
|
29
|
-
in this workflow viz marking_attendace, notify_parents, give_extra_marks_for_consistency, notify_sitting_position, late_marking, notify_missing_registration
|
31
|
+
scools, gym, private companies. Now lets say you have 5 'operations' that can happen in this workflow viz., marking_attendace, notify_parents, give_extra_marks_for_consistency, notify_sitting_position, late_marking, notify_missing_registration
|
30
32
|
notify_number_of_late_marks
|
31
33
|
|
32
34
|
After installing, first generate a workflow e.g. attendance_management in example above.
|
@@ -51,6 +53,7 @@ $ rails generate nayati:operation attendance_management marking_attendance
|
|
51
53
|
Next we will configure a workflow for a tenant. Lets say we are going to identify this workflow by name 'tenant_1_attendance_marking'. This tenant is a school and needs only marking_attendance and late_marking piece of functionality and if marking_attendance fails, you are supposed to nottify to register first. Nayati comes with a method to configure a workflow in database.
|
52
54
|
|
53
55
|
workflow_hash corresponding to sequence mentioned in above paragraph would be
|
56
|
+
```ruby
|
54
57
|
workflow_sequence_hash = {
|
55
58
|
name: 'marking_attendance',
|
56
59
|
workflow_identifier: 'tenant_1_attendance_marking',
|
@@ -61,19 +64,29 @@ workflow_sequence_hash = {
|
|
61
64
|
{ name: 'late_marking'}
|
62
65
|
]
|
63
66
|
}
|
67
|
+
```
|
64
68
|
|
65
69
|
You can put this workflow in database by calling
|
66
70
|
```ruby
|
67
71
|
Nayati::Workflow.create_or_update_from_workflow_json(workflow_sequence_hash)
|
68
72
|
```
|
69
73
|
|
74
|
+
If you want to print sequence of a workflow already in database you can do
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
workflow_record.entire_workflow_as_hash
|
78
|
+
```
|
79
|
+
|
80
|
+
This will return a hash with a structure same as the one we used for creating workflow.
|
81
|
+
|
82
|
+
|
70
83
|
Next we will have a look at operation class
|
71
|
-
nayati:operation will generate operation class in app/nayati_operations/{workflow_name}/ directory which will automatically be initialized with operation_context that you created in nayati service class and result object when you call the 'call' method on service class.
|
72
84
|
|
73
|
-
|
85
|
+
nayati:operation generator will generate operation class in app/nayati_operations/{workflow_name}/ directory which will automatically be initialized with operation_context that you created in nayati service class and result object.
|
86
|
+
|
87
|
+
Operation class implements to_fail?, perform_failure, perform methods. In our example marking_attendance operation should implement to_fail? in such a way that it returns false if fingerprint does not match. If not implemented, to_fail? by default returns false.
|
74
88
|
|
75
|
-
|
89
|
+
By default nayati will first call to_fail? method of a operation class starting with initial operation. If this method returns true, nayati will call perform_failure and next operation will be after_failure operation configured in database. If this method returns false, nayati will call perform method and next operation will be after_success operation configured in database. Nayati will stop when there is no operation to run.
|
76
90
|
|
77
|
-
You can find a sample multitenant application here.
|
78
91
|
## License
|
79
92
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/nayati/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nayati
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanmay Tupe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -34,22 +34,16 @@ dependencies:
|
|
34
34
|
name: activerecord
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.2'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
39
|
+
version: '0'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.2'
|
50
44
|
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
46
|
+
version: '0'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: mysql2
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|