Sha256: e8f3b44dc005559cc9c5f42d9a363542621c9c007302eff9412b003af42cbd1d
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Exclaim module Implementations IF_HELPER = ->(config, _env) do # 'condition' is the shorthand property for this helper, # but "config['condition']" will return the falsy value nil if that key # does not exist in the config. That will happen when the condition is configured # with the shorthand property "{ '$if' => <some value> }" # # Therefore it is necessary to check for the 'condition' key to find configuration like # "{ 'condition' => false }" or an even explicit "{ 'condition' => nil }" # Then we fall back to the shorthand property if the 'condition' key does not exist. condition = if config.key?('condition') config['condition'] else config['$if'] end if condition config['then'] unless config['then'].nil? else config['else'] end end IF_HELPER.define_singleton_method(:helper?) { true } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-exclaim-0.1.1 | lib/exclaim/implementations/if_helper.rb |
ruby-exclaim-0.1.0 | lib/exclaim/implementations/if_helper.rb |
ruby-exclaim-0.0.0 | lib/exclaim/implementations/if_helper.rb |