pathway 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -4
- data/lib/pathway/plugins/sequel_models.rb +21 -18
- data/lib/pathway/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44064358d4eecc254675bd8c06339391665f2bc7
|
4
|
+
data.tar.gz: 7572f812298d4967f4bb4524a837e3bb2a073112
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb09576e32c06454c5eeb0493ebfe95c110db6551047b5cecd2c977cb0effd784e6079f04db7a47bfb4f9bb77fbdffd9bc7cbdd3031579f22a083d69bd8f63aa
|
7
|
+
data.tar.gz: 2a9bb5f9e1ec76a287e737c430830f5ece21dde19a9d53f9a448cb11ef929ee81a99708c6719a7d06a35c0b99da23ae28a10607128fc03c9c8c0b9524582bbd4
|
data/README.md
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
[![CircleCI](https://circleci.com/gh/pabloh/pathway/tree/master.svg?style=shield)](https://circleci.com/gh/pabloh/pathway/tree/master)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/pabloh/pathway/badge.svg?branch=master)](https://coveralls.io/github/pabloh/pathway?branch=master)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
TODO: Delete this and the text above, and describe your gem
|
7
|
+
Pathway allows you to encapsulate your app's business logic into operation objects (also known as application services on the DDD lingo).
|
10
8
|
|
11
9
|
## Installation
|
12
10
|
|
@@ -24,9 +22,37 @@ Or install it yourself as:
|
|
24
22
|
|
25
23
|
$ gem install pathway
|
26
24
|
|
25
|
+
## Introduction
|
26
|
+
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
|
29
|
+
### Core API and concepts
|
30
|
+
|
31
|
+
#### Function objects (`call` methods)
|
32
|
+
#### Steps
|
33
|
+
##### Succesful
|
34
|
+
##### Failed
|
35
|
+
#### Operation result
|
36
|
+
#### Initialization and context
|
37
|
+
#### Execution process state
|
38
|
+
#### Result value
|
39
|
+
#### Alternative invocation syntaxes and pattern matching DSL
|
40
|
+
|
41
|
+
### Plugins
|
42
|
+
#### Plugin architecture
|
43
|
+
|
44
|
+
#### `SimpleAuth` plugin
|
45
|
+
#### `DryValidation` plugin
|
46
|
+
#### `SequelModels` plugin
|
47
|
+
#### `Responder` plugin
|
48
|
+
|
49
|
+
### Testing tools
|
50
|
+
#### Rspec config
|
51
|
+
#### Rspec matchers
|
52
|
+
|
53
|
+
## Best practices
|
54
|
+
### Operation object design and organization
|
55
|
+
### Testing recomendations
|
30
56
|
|
31
57
|
## Development
|
32
58
|
|
@@ -21,29 +21,28 @@ module Pathway
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
module
|
25
|
-
|
26
|
-
def self.[](model_class, by: :id)
|
27
|
-
Module.new do
|
28
|
-
include InstanceMethods
|
24
|
+
module ClassMethods
|
25
|
+
attr_accessor :model_class, :search_field
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def model(model_class, search_by: :id, set_result_key: true)
|
28
|
+
self.model_class = model_class
|
29
|
+
self.search_field = search_by
|
30
|
+
self.result_key = Inflecto.underscore(model_class.name.split('::').last).to_sym if set_result_key
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
33
|
+
def inherited(subclass)
|
34
|
+
super
|
35
|
+
subclass.model_class = model_class
|
36
|
+
subclass.search_field = search_field
|
41
37
|
end
|
38
|
+
end
|
42
39
|
|
40
|
+
module InstanceMethods
|
43
41
|
extend Forwardable
|
44
|
-
delegate %i[model_class
|
42
|
+
delegate %i[model_class search_field] => 'self.class'
|
43
|
+
delegate :db => :model_class
|
45
44
|
|
46
|
-
def fetch_model(state, from: model_class, key:
|
45
|
+
def fetch_model(state, from: model_class, key: search_field, column: search_field, overwrite: false)
|
47
46
|
if state[result_key].nil? || overwrite
|
48
47
|
find_model_with(state[:input][key], from, column)
|
49
48
|
.then { |model| state.update(result_key => model) }
|
@@ -56,10 +55,14 @@ module Pathway
|
|
56
55
|
wrap(model_class.new(params))
|
57
56
|
end
|
58
57
|
|
59
|
-
def find_model_with(key, dataset = model_class, column =
|
58
|
+
def find_model_with(key, dataset = model_class, column = search_field)
|
60
59
|
wrap_if_present(dataset.first(column => key))
|
61
60
|
end
|
62
61
|
end
|
62
|
+
|
63
|
+
def self.apply(operation, model: nil, **args)
|
64
|
+
operation.model(model, args) if model
|
65
|
+
end
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
data/lib/pathway/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Herrero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|