Merge pull request #1747 from jsdalton/mode-check-helper

Add app method to detect mode
This commit is contained in:
Thomas Reynolds 2016-01-11 15:57:23 -08:00
commit 56d71fe7d6

View file

@ -327,18 +327,26 @@ module Middleman
end end
end end
# Whether we're in a specific mode
# @param [Symbol] key
# @return [Boolean]
Contract Symbol => Bool
def mode?(key)
config[:mode] == key
end
# Whether we're in server mode # Whether we're in server mode
# @return [Boolean] If we're in dev mode # @return [Boolean] If we're in dev mode
Contract Bool Contract Bool
def server? def server?
config[:mode] == :server mode?(:server)
end end
# Whether we're in build mode # Whether we're in build mode
# @return [Boolean] If we're in dev mode # @return [Boolean] If we're in dev mode
Contract Bool Contract Bool
def build? def build?
config[:mode] == :build mode?(:build)
end end
# Whether we're in a specific environment # Whether we're in a specific environment