motion_bindable 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 7ef10a54e768eb79857d0bd5539519a6b90932e0
4
- data.tar.gz: cf500b93047492d2fb8dfbeba5c9b70e386c6f29
3
+ metadata.gz: 6e15764cf078511d391ab77e8c77892e481e1265
4
+ data.tar.gz: ebcd86f5aa9f55136c862f613aa4f92f9acc99b1
5
5
  SHA512:
6
- metadata.gz: 3ff1166dc058c57b9fa4adaea29eef1a328e0061c49a6d831edf0986a5aed0486066988471f17f5581f658ee58489c927b6c7381643bfc1b101f57df765edd1e
7
- data.tar.gz: bda1bc7c69f24ca5fe4046cf4cc4dce45a66cc3a8160d76459f445eea30448d63d4954b32c1c75f1c7fb6339a61a4e63155e7d1ae3432654be23a00dec036fae
6
+ metadata.gz: 22091ff0cca1dcece85d46ed15b7c96898394d79e9e9c6ebd0cd135639266ff3d5a732bd87f0618836537398de3176b76482987e3df7b96f656f39103b15f982
7
+ data.tar.gz: 60bdd993b4fea52803026400e50411962423c916327f20ec68fb099490eb864cca084cf11cf5c9cc75606534c1526af86080177b64c417525cc466f6b3dd2b79
data/.gemrelease ADDED
@@ -0,0 +1,3 @@
1
+ bump:
2
+ tag: true
3
+ release: true
@@ -29,6 +29,7 @@ module MotionBindable
29
29
 
30
30
  def refresh
31
31
  @bindings.each { |b| b.refresh }
32
+ self
32
33
  end
33
34
 
34
35
  private
@@ -1,3 +1,3 @@
1
1
  module MotionBindable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,17 @@
1
+ module MotionBindable::Strategies
2
+
3
+ class Proc < ::MotionBindable::Strategy
4
+
5
+ def refresh
6
+ update_attribute
7
+ end
8
+
9
+ private
10
+
11
+ def update_attribute
12
+ self.attribute = bound.call
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -13,6 +13,7 @@ describe 'MotionBindable::Bindable' do
13
13
  @object = FakeBindable.new
14
14
  @bound = Object.new
15
15
  @object.stub!(:strategy_for) { |_| FakeStrategy }
16
+ @strategy = FakeStrategy.new(@object, :attribute)
16
17
  end
17
18
 
18
19
  describe '#bind_attributes' do
@@ -45,15 +46,16 @@ describe 'MotionBindable::Bindable' do
45
46
  end
46
47
 
47
48
  describe '#bind' do
48
-
49
- before do
50
- @strategy = FakeStrategy.new(@object, :attribute)
51
- end
52
-
53
49
  it 'should be chainable' do
54
50
  @object.bind(@strategy).should.equal @object
55
51
  end
52
+ end
56
53
 
54
+ describe '#refresh' do
55
+ it 'should be chainable' do
56
+ @object.bind(@strategy)
57
+ @object.refresh.should.equal @object
58
+ end
57
59
  end
58
60
 
59
61
  end
@@ -0,0 +1,56 @@
1
+ class FakeBound
2
+ attr_accessor :attribute
3
+ end
4
+
5
+ class FakeModel
6
+ include MotionBindable::Bindable
7
+ attr_accessor :attribute
8
+ attr_accessor :nested
9
+ end
10
+
11
+ describe 'MotionBindable::Strategies::Proc' do
12
+
13
+ before do
14
+ MotionBindable::Strategy.register_strategy(
15
+ MotionBindable::Strategies::Proc,
16
+ Proc
17
+ )
18
+ end
19
+
20
+ context 'nested model' do
21
+
22
+ before do
23
+ @bound = FakeBound.new
24
+ @bound.attribute = 'Testing.'
25
+ @object = FakeModel.new
26
+ @object.nested = FakeModel.new
27
+ end
28
+
29
+ context 'is bound' do
30
+
31
+ before do
32
+ @object.bind_attributes({
33
+ attribute: proc { @bound.attribute },
34
+ nested: {
35
+ attribute: proc { @bound.attribute }
36
+ }
37
+ })
38
+ end
39
+
40
+ it 'should refresh upon bind' do
41
+ @object.attribute.should.equal 'Testing.'
42
+ @object.nested.attribute.should.equal 'Testing.'
43
+ end
44
+
45
+ it 'can refresh manually' do
46
+ @bound.attribute = 'Updated.'
47
+ @object.refresh.attribute.should.equal 'Updated.'
48
+ @object.refresh.nested.attribute.should.equal 'Updated.'
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion_bindable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kot
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - .gemrelease
20
21
  - .gitignore
21
22
  - Gemfile
22
23
  - Gemfile.lock
@@ -29,11 +30,13 @@ files:
29
30
  - lib/motion_bindable/delegate_proxy.rb
30
31
  - lib/motion_bindable/strategy.rb
31
32
  - lib/motion_bindable/version.rb
33
+ - lib/strategies/proc.rb
32
34
  - lib/strategies/strategies.rb
33
35
  - lib/strategies/ui_text_field.rb
34
36
  - motion_bindable.gemspec
35
37
  - resources/Default-568h@2x.png
36
38
  - spec/bindable_spec.rb
39
+ - spec/proc_strategy_spec.rb
37
40
  - spec/strategy_spec.rb
38
41
  - spec/ui_text_field_strategy_spec.rb
39
42
  homepage: ''
@@ -62,5 +65,6 @@ specification_version: 4
62
65
  summary: Inspired by RivetsJS
63
66
  test_files:
64
67
  - spec/bindable_spec.rb
68
+ - spec/proc_strategy_spec.rb
65
69
  - spec/strategy_spec.rb
66
70
  - spec/ui_text_field_strategy_spec.rb