Method: Dynamini::TestClient#apply_filter_options

Defined in:
lib/dynamini/test_client.rb

#apply_filter_options(parent, args, start_val, end_val) ⇒ Object



146
147
148
149
150
151
152
153
# File 'lib/dynamini/test_client.rb', line 146

def apply_filter_options(parent, args, start_val, end_val)
  records = parent.values
  records = records.select { |record| record[@range_key_attr] >= start_val.to_f } if start_val
  records = records.select { |record| record[@range_key_attr] <= end_val.to_f } if end_val
  records = records.sort! { |a, b| b[@range_key_attr] <=> a[@range_key_attr] } if args[:scan_index_forward] == false
  records = records[0...args[:limit]] if args[:limit]
  records
end