various small refactorings

This commit is contained in:
Reinier Balt 2013-09-22 17:34:58 +02:00
parent 10d3bc783c
commit 067db90d58
4 changed files with 90 additions and 43 deletions

View file

@ -80,7 +80,11 @@ module IsTaggable
end
end
def tag_cast_to_string obj
def tag_cast_to_string(obj)
tag_array_from_obj(obj).flatten.compact.map(&:downcase).uniq
end
def tag_array_from_obj(obj)
case obj
when Array
obj.map! { |item| get_tag_name_from_item(item) }
@ -88,7 +92,7 @@ module IsTaggable
obj.split(Tag::DELIMITER).map { |tag_name| tag_name.strip.squeeze(" ") }
else
raise "Invalid object of class #{obj.class} as tagging method parameter"
end.flatten.compact.map(&:downcase).uniq
end
end
end