moory 0.4.0 → 0.5.0

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: 28123aa5014d091460be8427c963f0cba5516dd319eca1e4e14ebcfed6fa4040
4
- data.tar.gz: a6bfbc1b04c2ec1f2910f5eb01dc17515f99fe3ae6040ae4e5c48d03b39e5703
3
+ metadata.gz: 7803ea588168060b163caa8728fa356b68af3c614de292dded36524e416f1023
4
+ data.tar.gz: c82553499326caca18e06c4983d31228aa4c336b6324432d3144cff707216071
5
5
  SHA512:
6
- metadata.gz: 2e57244347beccfa883a776443b56b3beaed903a06582fec89810896546a180c191cb301384e1ebabac460b887f61706540c4fb6677ce0e1e0f6d70eea714138
7
- data.tar.gz: 4cf05c5208129d257b6b3c7e4a5b139af5f64500c9aed726d1bcf1a53c8f8cd504af5756c5736dd023d0dab67dbe0fd22ba50212a3e88226dc1f8c8f0b75955c
6
+ metadata.gz: f3dc36b5e79c7464f689c77e4dd1850d60f351b1bb9a21425f1c3712ea726dc491d839428f0efe071a4c9039f478911324891e0bed564ebf5f479f1b8a1b75a1
7
+ data.tar.gz: 0c8ba949d79bc6c80b4c7a94894d6842d353fa4d234e4f8507db7e9c018192886ac11fb3fa9b29e52bd67fe801fc4298ec907db851333a28372630465831e5b0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moory (0.4.0)
4
+ moory (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,10 +8,11 @@ module Moory
8
8
  SKIP = proc {}
9
9
  WARN = proc { |msg| warn "Did not understand: #{msg}" }
10
10
 
11
- def initialize(graph: {}, effectors: {}, default_proc: SKIP, &block)
11
+ def initialize(graph: {}, effectors: {}, default_proc: SKIP, fallback_always: true, &block)
12
12
  @graph = graph
13
13
  @effectors = effectors
14
14
  @default_proc = default_proc
15
+ @fallback_always = fallback_always
15
16
 
16
17
  instance_eval &block if block_given?
17
18
  end
@@ -27,6 +28,10 @@ module Moory
27
28
  @fallback_effector = candidate.respond_to?(:call) ? candidate : nil
28
29
  end
29
30
 
31
+ def fallback_always=(bool)
32
+ @fallback_always = bool
33
+ end
34
+
30
35
  def default_proc=(obj)
31
36
  @default_proc = obj.respond_to?(:call) ? obj : nil
32
37
  end
@@ -85,10 +90,14 @@ module Moory
85
90
  if candidate.kind_of?(String)
86
91
  effectors[candidate]
87
92
  else
88
- candidate || fallback_effector
93
+ candidate || (fallback_effector if fallback_appropriate_for?(msg))
89
94
  end
90
95
  end
91
96
 
97
+ def fallback_appropriate_for?(msg)
98
+ @fallback_always ? @fallback_always : output(msg)
99
+ end
100
+
92
101
  def output(msg)
93
102
  graph[state][msg][:output]
94
103
  end
@@ -1,3 +1,3 @@
1
1
  module Moory
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam W. Grant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler