mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix case with no tags and some metadata
Simplify tag set construction code.
This commit is contained in:
parent
467f0d3ad4
commit
5166cd7778
2 changed files with 32 additions and 32 deletions
|
@ -27,10 +27,10 @@ module Spectator::DSL
|
|||
\{% raise "Block argument count '{{name.id}}' hook must be 0..1" if block.args.size > 1 %}
|
||||
|
||||
def self.\%tags
|
||||
\{% if tags.empty? && metadata.empty? %}
|
||||
_spectator_tags
|
||||
\{% else %}
|
||||
_spectator_tags.concat({\{{tags.map(&.id.stringify).splat}}}).tap do |tags|
|
||||
tags = _spectator_tags
|
||||
\{% if !tags.empty? %}
|
||||
tags.concat({ \{{tags.map(&.id.stringify).splat}} })
|
||||
\{% end %}
|
||||
\{% for k, v in metadata %}
|
||||
cond = begin
|
||||
\{{v}}
|
||||
|
@ -38,11 +38,10 @@ module Spectator::DSL
|
|||
if cond
|
||||
tags.add(\{{k.id.stringify}})
|
||||
else
|
||||
tags.remove(\{{k.id.stringify}})
|
||||
end
|
||||
\{% end %}
|
||||
tags.delete(\{{k.id.stringify}})
|
||||
end
|
||||
\{% end %}
|
||||
tags
|
||||
end
|
||||
|
||||
def \%test(\{{block.args.splat}}) : Nil
|
||||
|
|
|
@ -16,11 +16,12 @@ module Spectator::DSL
|
|||
class Group\%group < \{{@type.id}}
|
||||
_spectator_group_subject(\{{what}})
|
||||
|
||||
\{% if !tags.empty? || !metadata.empty? %}
|
||||
def self._spectator_tags
|
||||
\{% if tags.empty? && metadata.empty? %}
|
||||
super
|
||||
\{% else %}
|
||||
super.concat({\{{tags.map(&.id.stringify).splat}}}).tap do |tags|
|
||||
tags = super
|
||||
\{% if !tags.empty? %}
|
||||
tags.concat({ \{{tags.map(&.id.stringify).splat}} })
|
||||
\{% end %}
|
||||
\{% for k, v in metadata %}
|
||||
cond = begin
|
||||
\{{v}}
|
||||
|
@ -28,12 +29,12 @@ module Spectator::DSL
|
|||
if cond
|
||||
tags.add(\{{k.id.stringify}})
|
||||
else
|
||||
tags.remove(\{{k.id.stringify}})
|
||||
tags.delete(\{{k.id.stringify}})
|
||||
end
|
||||
\{% end %}
|
||||
tags
|
||||
end
|
||||
\{% end %}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.start_group(
|
||||
_spectator_group_name(\{{what}}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue