mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-21 18:42:29 +01:00
Filter symbols
This commit is contained in:
parent
631d42207b
commit
15092bce7b
12
lib/app.rb
12
lib/app.rb
@ -6,10 +6,20 @@ require 'yajl'
|
||||
set :root, File.expand_path('..', File.dirname(__FILE__))
|
||||
|
||||
helpers do
|
||||
# Ugly as fuck.
|
||||
def snapshot
|
||||
Snapshot
|
||||
symbols = params.delete('symbols') || params.delete('currencies')
|
||||
|
||||
quote = Snapshot
|
||||
.new(params)
|
||||
.quote
|
||||
|
||||
if symbols
|
||||
symbols = symbols.split ','
|
||||
quote[:rates].keep_if { |k, v| symbols.include? k }
|
||||
end
|
||||
|
||||
quote
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,7 +20,6 @@ describe 'the application' do
|
||||
end
|
||||
|
||||
it 'filters symbols' do
|
||||
skip 'enterprise feature'
|
||||
get '/latest?symbols=USD'
|
||||
json['rates'].keys.must_equal %w(USD)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user