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 +4 -4
- data/.gemrelease +3 -0
- data/lib/motion_bindable/bindable.rb +1 -0
- data/lib/motion_bindable/version.rb +1 -1
- data/lib/strategies/proc.rb +17 -0
- data/spec/bindable_spec.rb +7 -5
- data/spec/proc_strategy_spec.rb +56 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e15764cf078511d391ab77e8c77892e481e1265
|
4
|
+
data.tar.gz: ebcd86f5aa9f55136c862f613aa4f92f9acc99b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22091ff0cca1dcece85d46ed15b7c96898394d79e9e9c6ebd0cd135639266ff3d5a732bd87f0618836537398de3176b76482987e3df7b96f656f39103b15f982
|
7
|
+
data.tar.gz: 60bdd993b4fea52803026400e50411962423c916327f20ec68fb099490eb864cca084cf11cf5c9cc75606534c1526af86080177b64c417525cc466f6b3dd2b79
|
data/.gemrelease
ADDED
data/spec/bindable_spec.rb
CHANGED
@@ -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.
|
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
|