Untitled
unknown
plain_text
3 years ago
1.1 kB
7
Indexable
class Tag
TAG_SETTINGS = {}
def self.profile_tag_groups
TAG_SETTINGS['profile_tag_groups'] || []
end
def self.video_tag_groups
TAG_SETTINGS['video_tag_groups'] || []
end
def self.single_tag_groups
TAG_SETTINGS['single_tag_groups'] || []
end
def self.map_for_profile
video_tag_groups.each_with_object({}) do |method_name, result|
result[method_name] = get_tag_group(method_name).keys
end
end
def self.map_for_video
video_tag_groups.each_with_object({}) do |method_name, result|
result[method_name] = get_tag_group(method_name).values.uniq
end
end
def self.single?(tag)
tag.in? single_tag_groups
end
def self.multiple?(tag)
!single?(tag)
end
def self.permited_attrs
profile_tag_groups.each_with_object([]) do |method_name, result|
result << (single?(method_name) ? method_name : { method_name => [] })
end
end
def self.find_video_tags(tags)
video_tag_groups.inject([]) do |result, method_name|
result + get_tag_group(method_name).slice(*tags).values
end.uniq
end
def self.get_tag_group(name)
TAG_SETTINGS[name]
end
end
Editor is loading...