Skip to content

Commit

Permalink
transfer keys methods
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Jul 5, 2018
1 parent 0de818f commit d3eec43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/models/cita_sync/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ def conn
def cita_url
ENV.fetch("CITA_URL")
end

# make params key chainId => chain_id
# not deep transfer keys, only transfer first level keys
def transfer_params(params)
params.map { |k, v| { k.to_s.underscore => v } }.reduce(:merge)
end

# select params
def select_params(params, keys = [])
underscore_params = transfer_params(params)
underscore_params.select { |k, _v| keys.include?(k) }
end
end

end
Expand Down

0 comments on commit d3eec43

Please sign in to comment.