ine-places 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f493d2dcb6ff27f737d8cd440b7f40d19ddc641
4
- data.tar.gz: 134911a07f947153b7b13be922714df90644d066
3
+ metadata.gz: 37968cbbe43babded7fa90ed6443e4a3bf468ab0
4
+ data.tar.gz: a1a1cce2d4ddda066214c7687236ca9c57a15a96
5
5
  SHA512:
6
- metadata.gz: ace4ecc42cfa96bc60015318e3b7d5aa075261420233d03a0fa8f44c48981276141cf6025c459193864e9bff60d20e51a5ceb22b16bc4cd7bfac063a6de0b7f0
7
- data.tar.gz: f236a3d158ec2728ed01d9dac4eeb13c378bd65b03caf51a19af1246ce5d19fae562174c5d0600acd3d1eafbf6b89ced374b3e673d9b9967fe2d6ff6e98a8ea2
6
+ metadata.gz: 3a962e604b8ffd396d685e004bdfac84e757795b5b8794e5fa8eb8d8389e8e80145ba3ea3686aba2f21f738db7c364c6c2cb9704a9123aa46a21b3930741b925
7
+ data.tar.gz: ea1e7bb6c4089962ab6a09a9de2184fad1385affe22cd92e7ad914f69341a977e37d65be14450803b551bcb2dcd3315167703079cd2e2b5d8e1447a26a3a111a
@@ -14,19 +14,33 @@ module INE::Places::CSVRecord
14
14
  def find_by_name(name)
15
15
  raise ArgumentError if name.blank?
16
16
 
17
- collection_klass.records.detect{|obj| obj.name == name }
17
+ records_by_name[name]
18
18
  end
19
19
 
20
20
  def find_by_slug(slug)
21
21
  raise ArgumentError if slug.blank?
22
22
 
23
- collection_klass.records.detect{|obj| obj.slug == slug }
23
+ records_by_slug[slug]
24
24
  end
25
25
 
26
26
  def find(id)
27
27
  raise ArgumentError if id.blank?
28
28
 
29
- collection_klass.records.detect{|obj| obj.id.to_i == id.to_i }
29
+ records_by_id[id.to_i]
30
+ end
31
+
32
+ private
33
+
34
+ def records_by_id
35
+ @records_by_id ||= Hash[collection_klass.records.map{ |record| [record.id.to_i, record] }]
36
+ end
37
+
38
+ def records_by_slug
39
+ @records_by_slug ||= Hash[collection_klass.records.map{ |record| [record.slug, record] }]
40
+ end
41
+
42
+ def records_by_name
43
+ @records_by_name ||= Hash[collection_klass.records.map{ |record| [record.name, record] }]
30
44
  end
31
45
  end
32
46
  end
@@ -1,5 +1,5 @@
1
1
  module INE
2
2
  module Places
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ine-places
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Blat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport