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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d663654bb798cc6cc600aac2c1ef9169fd9c1ec1
4
- data.tar.gz: 6d062ab2a76e2966d6022fd2b96829e551240cf1
3
+ metadata.gz: 44064358d4eecc254675bd8c06339391665f2bc7
4
+ data.tar.gz: 7572f812298d4967f4bb4524a837e3bb2a073112
5
5
  SHA512:
6
- metadata.gz: bf5ba3f7289bdc7c0db4e4ba5eec6827d8b2acd9061962143ec3ca643909dcb7accb6dc14c05fcb64754dbac21dfcf4c3bc6d13e9c9454d7cb66a83667428d8a
7
- data.tar.gz: fd8c55ce09f11629280d9b1c5279dfe4c3aff68f92a58b34d9f33ab39d68c454acd7d525d2502f67de450ab4848f30b011b659930ccca0943ec8954567e37a30
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pathway`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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 InstanceMethods
25
- module Finder
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
- define_singleton_method :included do |klass|
31
- klass.class_eval do
32
- result_at Inflecto.underscore(model_class.name.split('::').last).to_sym
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
- define_method(:model_class) { model_class }
35
- define_method(:field) { by }
36
- define_method(:db) { model_class.db }
37
- end
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 db field] => 'self.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: field, column: field, overwrite: false)
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 = field)
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
@@ -1,3 +1,3 @@
1
1
  module Pathway
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
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.15
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-19 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inflecto