mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 07:10:12 +01:00
various small refactorings
This commit is contained in:
parent
10d3bc783c
commit
067db90d58
4 changed files with 90 additions and 43 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue