File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,26 @@ def has_tag? tag
4949 false # tag doesn't exist if we got here
5050 end
5151
52+ def tags ( key = nil )
53+ tags = { }
54+ selected . each do |view |
55+ view . rmq_data . tags . each do |tag , data |
56+ tags [ tag ] ||= [ ]
57+ tags [ tag ] << data
58+ end
59+ end
60+ tags = tags . inject ( { } ) do |hash , ( k , v ) |
61+ hash [ k ] = v . length == 1 ? v . first : v
62+ hash
63+ end
64+
65+ if key
66+ tags [ key ]
67+ else
68+ tags
69+ end
70+ end
71+
5272 # See /motion/data.rb for the rest of the tag stuff
5373
5474 end
Original file line number Diff line number Diff line change 7474 end
7575 end
7676
77+ it 'should return the tags for the selection' do
78+ @vc . rmq . append ( UIView ) . tag ( data : "some-data" )
79+ @vc . rmq . append ( UIView ) . tag ( other_data : "other-data" )
80+ @vc . rmq . all . tags . should == { data : "some-data" , other_data : "other-data" }
81+ end
82+
83+ it 'should be able to return tag data' do
84+ @vc . rmq . append ( UIView ) . tag ( data : "some-data" ) . tap do |q |
85+ q . tags ( :data ) . should == "some-data"
86+ end
87+ end
88+
89+ it 'should return an array of data if there are duplicate tags in the selection' do
90+ @vc . rmq . append ( UIView ) . tag ( data : "some-data" )
91+ @vc . rmq . append ( UIView ) . tag ( data : "other-data" )
92+ @vc . rmq . all . tags ( :data ) . should == [ "some-data" , "other-data" ]
93+ end
94+
7795end
You can’t perform that action at this time.
0 commit comments