mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 17:52:17 +08:00
Merge pull request #178 from jjnevis/add-delete-tag-feature
Add delete tag feature
This commit is contained in:
@@ -32,6 +32,16 @@ module RubyMotionQuery
|
||||
end
|
||||
end
|
||||
|
||||
# *Do not* use this, use {RMQ#untag} instead:
|
||||
# @example
|
||||
# rmq(my_view).untag(:foo, :bar)
|
||||
# Do nothing if no tag supplied or tag not present
|
||||
def untag(*tag_or_tags)
|
||||
tag_or_tags.flatten.each do |tag_name|
|
||||
tags.delete tag_name
|
||||
end
|
||||
end
|
||||
|
||||
# Check if this view contains a specific tag
|
||||
#
|
||||
# @param tag_name name of tag to check
|
||||
|
||||
@@ -20,6 +20,13 @@ module RubyMotionQuery
|
||||
self
|
||||
end
|
||||
|
||||
def untag(*tag_or_tags)
|
||||
selected.each do |view|
|
||||
view.rmq_data.untag(tag_or_tags)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
# @return [RMQ]
|
||||
def clear_tags
|
||||
selected.each do |view|
|
||||
|
||||
19
spec/tags.rb
19
spec/tags.rb
@@ -4,19 +4,34 @@ describe 'tags' do
|
||||
@root_view = @vc.view
|
||||
end
|
||||
|
||||
it 'should tag a view with a single tag' do
|
||||
it 'should tag and untag a view with a single tag' do
|
||||
@vc.rmq.append(UIView).tap do |q|
|
||||
q.tag(:foo)
|
||||
q.get.rmq_data.tags.should.include :foo
|
||||
q.get.rmq_data.tags.should.not.include :bar
|
||||
q.untag(:foo)
|
||||
q.get.rmq_data.tags.should.not.include :foo
|
||||
end
|
||||
end
|
||||
|
||||
it 'should tag a view with a multiple tags' do
|
||||
it 'should tag and untag a view with a multiple tags' do
|
||||
@vc.rmq.append(UIView).tap do |q|
|
||||
q.tag(:foo, :bar)
|
||||
q.get.rmq_data.tags.should.include :foo
|
||||
q.get.rmq_data.tags.should.include :bar
|
||||
q.untag(:foo, :bar)
|
||||
q.get.rmq_data.tags.should.not.include :foo
|
||||
q.get.rmq_data.tags.should.not.include :bar
|
||||
end
|
||||
end
|
||||
|
||||
it 'should only untag if tag exists' do
|
||||
@vc.rmq.append(UIView).tap do |q|
|
||||
q.tag(:foo)
|
||||
q.untag(:bar)
|
||||
q.untag(:bar, :baz)
|
||||
q.untag
|
||||
q.get.rmq_data.tag_names.should == [:foo]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user