module Plug
Constants
- VERSION
Public Instance Methods
enabled?(arg)
click to toggle source
- enabled? returns true of false
-
@param arg [String, Symbol] The slug or name of the Feature
@return [Boolean] true - Feature found and enabled | true - Feature not found (We don't want to block) | false - Feature was set to disabled
# File lib/plug.rb, line 16 def enabled?(arg) get_feature(arg).enabled? rescue StandardError true end
notice(arg, &block)
click to toggle source
Returns the notice of a given Feature @param arg [String] The slug or name of the Feature @param &block [Proc] The block of HTML/String for the notice
@return [String] The block of HTML/String with notice
# File lib/plug.rb, line 28 def notice(arg, &block) feature = get_feature(arg) render_notice(feature.notice, &block) unless feature.enabled? || feature.notice.blank? rescue StandardError nil end
Private Instance Methods
get_feature(arg)
click to toggle source
# File lib/plug.rb, line 38 def get_feature(arg) arg = arg.to_s if arg.is_a? Symbol return Plug::Feature.slug_and_name(arg).first end
render_notice(notice) { |notice| ... }
click to toggle source
# File lib/plug.rb, line 44 def render_notice(notice, &block) return notice unless block_given? yield(notice) end