Skip to content

Commit

Permalink
clean helpers module
Browse files Browse the repository at this point in the history
  • Loading branch information
yalongzhang authored and dblock committed Feb 25, 2016
1 parent 76bfa8f commit df3e4ae
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/grape/dsl/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ def helpers(new_mod = nil, &block)
if block_given? || new_mod
mod = new_mod || Module.new
define_boolean_in_mod(mod)
if new_mod
inject_api_helpers_to_mod(new_mod) if new_mod.is_a?(BaseHelper)
end
if block_given?
inject_api_helpers_to_mod(mod) do
mod.class_eval(&block)
end
end
inject_api_helpers_to_mod(mod) if new_mod
inject_api_helpers_to_mod(mod) do
mod.class_eval(&block)
end if block_given?

namespace_stackable(:helpers, mod)
else
Expand All @@ -58,7 +54,7 @@ def define_boolean_in_mod(mod)
end

def inject_api_helpers_to_mod(mod, &_block)
mod.extend(BaseHelper)
mod.extend(BaseHelper) unless mod.is_a?(BaseHelper)
yield if block_given?
mod.api_changed(self)
end
Expand Down

0 comments on commit df3e4ae

Please sign in to comment.