chainable_methods 0.1.0 → 0.1.1

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: c5e6dd0aa4131fb05e032f78d8f08987b53ff583
4
- data.tar.gz: d1d8166a40ee74921230eb87b300e5e79a9ed2ee
3
+ metadata.gz: d4bb132eff83680c2108d026320a9651a2d8f612
4
+ data.tar.gz: fecb905cf761a1b5a43c5f5dc3307bf4450e46d4
5
5
  SHA512:
6
- metadata.gz: 61e538c7b45a36cb162482b661383ada02b42cb307d8f4446674170886915132ca92ba92d4269f1d58f798ac08ce1c1c24f01db82e824aae4be27aec006d0f71
7
- data.tar.gz: f86214fbb1844b2fce900fb740c2712b40bc33bbd5ebeddf0f2524887223ccc3bdf68aabd8f532ed20a12759a7b5ebd3452b3bfa147409b3c8435ed0825f5949
6
+ metadata.gz: 0d4fa21b5a889ce08c598ead1283742050b10759e4c2ea8646ac8ff3c9e0a451e6c83dcc54491ef4e443c328003ad56d4490e63c2eb76fdeb938e8916d090664
7
+ data.tar.gz: 35efa65f538a0753db47973d30d2f799e45f7d0b4206dd88e85ce6fedab0d5fbd29ac1e458a919906f4ae7a5c1a262cf04b2cb4e4b02a3f539cc22eee6ad5bce
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -5,6 +5,10 @@ module ChainableMethods
5
5
  ChainableMethods::Link.new(initial_state, self)
6
6
  end
7
7
 
8
+ def self.wrap(context, initial_state)
9
+ ChainableMethods::Link.new(initial_state, context)
10
+ end
11
+
8
12
  class Link
9
13
  attr_reader :state, :context
10
14
 
@@ -14,7 +18,12 @@ module ChainableMethods
14
18
  end
15
19
 
16
20
  def method_missing(name, *args, &block)
17
- if state.respond_to?(name)
21
+ local_response = state.respond_to?(name)
22
+ context_response = context.respond_to?(name)
23
+
24
+ # if the state itself has the means to respond, delegate to it
25
+ # but if the context has the behavior, it has priority over the delegation
26
+ if local_response && !context_response
18
27
  ChainableMethods::Link.new( state.send(name, *args, &block), context)
19
28
  else
20
29
  ChainableMethods::Link.new( context.send(name, *([state] + args), &block), context )
@@ -26,3 +35,6 @@ module ChainableMethods
26
35
  end
27
36
  end
28
37
  end
38
+
39
+ # easier shortcut
40
+ CM ||= ChainableMethods
@@ -1,3 +1,3 @@
1
1
  module ChainableMethods
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chainable_methods
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
  - AkitaOnRails
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler