class Shamu::Features::Conditions::Env

Match against an environment variable.

Public Instance Methods

match?( context ) click to toggle source

(see Condition#match?)

# File lib/shamu/features/conditions/env.rb, line 9
def match?( context )
  variables.any? { |name, matcher| matcher.call( context.env( name ) ) }
end

Private Instance Methods

array_variables() click to toggle source
# File lib/shamu/features/conditions/env.rb, line 27
def array_variables
  Array( config ).each_with_object( {} ) do |name, hash|
    hash[name] = ->(v) { v.to_bool }
  end
end
hash_variables() click to toggle source
# File lib/shamu/features/conditions/env.rb, line 19
def hash_variables
  return unless config.is_a?( Hash )

  config.each_with_object( {} ) do |(name, value), hash|
    hash[name] = ->(v) { v == value }
  end
end
variables() click to toggle source
# File lib/shamu/features/conditions/env.rb, line 15
def variables
  @variables ||= hash_variables || array_variables
end