Support numeric inputs for the category
This commit is contained in:
@@ -71,6 +71,10 @@ class TagCategory
|
||||
def short_name_regex
|
||||
@@short_name_regex ||= short_name_list.join("|")
|
||||
end
|
||||
|
||||
def category_ids_regex
|
||||
@@category_ids_regex ||= "[#{category_ids.join("")}]"
|
||||
end
|
||||
end
|
||||
|
||||
extend Mappings
|
||||
|
||||
@@ -87,7 +87,14 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
def value_for(string)
|
||||
TagCategory.mapping[string.to_s.downcase] || 0
|
||||
norm_string = string.to_s.downcase
|
||||
if norm_string =~ /#{TagCategory.category_ids_regex}/
|
||||
norm_string.to_i
|
||||
elsif TagCategory.mapping[string.to_s.downcase]
|
||||
TagCategory.mapping[string.to_s.downcase]
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user