Skip to content

Commit

Permalink
:hurtrealbad: or it'd be cute if you just did tags=[whatever]
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kendall committed Dec 6, 2012
1 parent 18a9296 commit 8721c12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/dank/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def get_array
def set_array ary
redis.smembers("dank:sets:#{Dank.app_name}:#{@taggable_name}:#{@objekt.id}").each { |tag| remove tag }
ary.each {|tag| add tag }

reorder ary
end

Expand Down Expand Up @@ -205,8 +204,12 @@ def tag_name(name)
tag_lib.add tag
end

define_method :"set_#{name}s" do |tag|
tag_lib.set_array tag
define_method :"#{name}s=" do |tags|
if tags.kind_of? Array
tag_lib.set_array tags
else
false
end
end

define_method :"remove_#{name}" do |tag|
Expand Down
2 changes: 1 addition & 1 deletion spec/dank_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def id
user.genre_suggestions.should == ['rap']
user.remove_genre 'country'
user.genre_suggestions.should =~ ['rap', 'country']
user.set_genres(['rock', 'rap', 'instrumental_metal', 'screamo'])
user.genres = ['rock', 'rap', 'instrumental_metal', 'screamo']
user.genres.should == ['rock', 'rap', 'instrumental_metal', 'screamo']
end
end
Expand Down

0 comments on commit 8721c12

Please sign in to comment.