Skip to content

Commit

Permalink
Merge 778cecf into 6f35b6f
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm authored Jan 9, 2021
2 parents 6f35b6f + 778cecf commit 9764522
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/synvert/core/rewriter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class <<self
# @param name [String] the unique rewriter name.
# @param rewriter [Synvert::Core::Rewriter] the rewriter to register.
def register(group, name, rewriter)
group, name = group.to_s, name.to_s
group = group.to_s
name = name.to_s
rewriters[group] ||= {}
rewriters[group][name] = rewriter
end
Expand All @@ -61,7 +62,8 @@ def register(group, name, rewriter)
# @return [Synvert::Core::Rewriter] the matching rewriter.
# @raise [Synvert::Core::RewriterNotFound] if the registered rewriter is not found.
def fetch(group, name)
group, name = group.to_s, name.to_s
group = group.to_s
name = name.to_s
if exist? group, name
rewriters[group][name]
else
Expand All @@ -76,7 +78,8 @@ def fetch(group, name)
# @return [Synvert::Core::Rewriter] the registered rewriter.
# @raise [Synvert::Core::RewriterNotFound] if the registered rewriter is not found.
def call(group, name)
group, name = group.to_s, name.to_s
group = group.to_s
name = name.to_s
if exist? group, name
rewriter = rewriters[group][name]
rewriter.process
Expand All @@ -92,7 +95,8 @@ def call(group, name)
# @param name [String] the rewriter name.
# @return [Boolean] true if the rewriter exist.
def exist?(group, name)
group, name = group.to_s, name.to_s
group = group.to_s
name = name.to_s
if rewriters[group] && rewriters[group][name]
true
else
Expand Down

0 comments on commit 9764522

Please sign in to comment.