class DeadCodeTerminator::Cond::EnvFetch
ENV.fetch('PRODUCTION') s(:send,
s(:const, nil, :ENV), :fetch, s(:str, "PRODUCTION"))
Public Instance Methods
value()
click to toggle source
# File lib/dead_code_terminator/cond/env_fetch.rb, line 10 def value return if ast.type != :send receiver, method, *args = ast.children return unless receiver == s(:const, nil, :ENV) && method == :fetch return unless (matched_env_key = given_env_key(args[0])) env[matched_env_key] ? THEN : ELSE end
Private Instance Methods
given_env_key(ast)
click to toggle source
# File lib/dead_code_terminator/cond/env_fetch.rb, line 23 def given_env_key(ast) env.keys.detect { |key| ast == s(:str, key) } end