class Railroader::RouteAliasProcessor

This is for a really specific case where a hash is used as arguments to one of the map methods.

Public Instance Methods

get_keys(hash) click to toggle source

Returns an array Sexp containing the keys from the hash

# File lib/railroader/processors/lib/rails2_route_processor.rb, line 305
def get_keys hash
  keys = Sexp.new(:array)
  hash_iterate(hash) do |key, _value|
    keys << key
  end

  keys
end
process_call(exp) click to toggle source

This replaces { :some => :hash }.keys with

:some
# File lib/railroader/processors/lib/rails2_route_processor.rb, line 291
def process_call exp
  process_default exp

  if hash? exp.target and exp.method == :keys
    keys = get_keys exp.target
    exp.clear
    keys.each_with_index do |e, i|
      exp[i] = e
    end
  end
  exp
end