ar-ondemand 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzRhMGZlZGYyYzgyZTFmY2E5M2RkZDhkNjNkZmRhYmM4OTY1NmY2Ng==
4
+ ZThhOTU2ZmNlZGRlOTZmNWZiZTNlMDQxNjIwNzgwMzEyMTU0MGZhOA==
5
5
  data.tar.gz: !binary |-
6
- MzdlNmI1MDRlZWIyOGJkZWMzODVlYjljZjA0ZDFhMmMxMGRjNTc0YQ==
6
+ MWMyMTgzMGFkMjRhZjQ2YzNlNWI1OGIxNWM4OWIwMjJkMWQ0NWY2Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjJiNWNiZjg1YmYyYzJiMzE2ZWViMGY3ZTE5ZTg2ZTQ5Y2M5ZWYxNTU1MzBk
10
- NmM0ZmZhNWRlNTc2YTVmMjYzYTUyOGNhNGEyODY5MWJjNDQzMTA5YmRjNmRm
11
- NDQyMjVkOTAzOWFjZDEyZTM4NTQ5MjE0YzUwMDlmMTI5ZjIxN2M=
9
+ OWI0NWYxZDA1ODY3MDNmNjYwOWNiZjRkMmE4MDdlODA4MDA0NjBiOTliOWFm
10
+ MTA4NTVjYjBjNTU3MTQ3YzEyYTcxMTc5NGY0ZWNiY2M0NjJlYjNkMTVkZmZm
11
+ MzZiNjMzODllMjVhOTNhOWUyZTNmZTU2MmY2Zjk2ZjM3MDE1YWU=
12
12
  data.tar.gz: !binary |-
13
- MDZhZWNmZWI5MDE2ZmIyMzUwYzU1OWRjODY4Mzc0ODI4OWJmOGE2NzQzYjM2
14
- Nzk4ODE3ODJjNjBmNDA1MGNiZjJjYjk4ZDdjYWY4YTZlYWE4ZGUxOGViZDg2
15
- YjJkZjQ0NjIxYjgxYmVhYWVkODJkMjM4NjgxYTEyOGQwYjQwNjk=
13
+ MWVmZGY0ZjA2Y2ZmMjNhYTJlNzEwMDdiYzI3NjE4YWMzZDAzOGJlMjFhYjBl
14
+ ZDBhOWQ1Mjk5MDBjNmU4YTYwMzRjMmZjOGRkMzQxZjk1YTFkY2FmMDhiNDhh
15
+ YmViMTEwMTcwN2NhODc4MjAzN2IyNTE0NGUwYTZhMGFlMmQ3MTQ=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ar-ondemand (1.1.1)
4
+ ar-ondemand (1.1.2)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
 
@@ -23,11 +23,18 @@ module ActiveRecord
23
23
  @has_any_assets = !ids.empty? || @model.unscoped.where(@defaults).exists?
24
24
  @new_params = @defaults.dup
25
25
  @new_params[@key_column.to_sym] = nil
26
+ @results_to_hash = @results.rows.inject({}) do |h, row|
27
+ raise "Duplicate key found for result set: #{row[@key_index]}" if h.has_key? row[@key_index]
28
+ h[row[@key_index]] = row
29
+ h
30
+ end
31
+
32
+ self
26
33
  end
27
34
 
28
35
  def [](key)
29
36
  raise 'Search key cannot be blank.' if key.blank?
30
- rec = @results.rows.find { |x| x[@key_index] == key }
37
+ rec = @results_to_hash[key]
31
38
  if rec.nil?
32
39
  rec = if @has_any_assets
33
40
  args = @defaults.values + [key]
@@ -1,3 +1,3 @@
1
1
  module ArOnDemand
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-ondemand
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Frank