lazy_find 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 74847b1949a7a9aca83d6911a981548fc3a9aa66b5b4aaab12fdf4e616c5dfa3
4
- data.tar.gz: 447bf06e8be6363e4182d95836e72ecd2e7b9b5258d4c8c1dd88f36d8a4244f8
3
+ metadata.gz: c35f1177bc46404a6604d910ef5edae2bafad141bd28ae816a8af30c0dbef423
4
+ data.tar.gz: ef8d2c6a7daa61c0c0a4cfe56d09a4565f2424b03facdac459d3b5083ae7d312
5
5
  SHA512:
6
- metadata.gz: 2621f3328f2a140af12a31f2189d03859200c9b00e4dd979ea8d0947f9fbfa5887e256b74e018edaf53b48b549a9468a003f6c5b9f498e542c1f104021818e65
7
- data.tar.gz: 37349cbd69fd9a4c49e7f93856e7b555aec15bdbc380f453960409673d3d21b12abb76e3374273f429d018fcc636781e5e29e6e35b7a51fe40574edf47cacb4d
6
+ metadata.gz: 57f1c0e22f9070ce762ddf1a57e66b7333fde4dad699d7d5c71025c3af8ca86649dc9fb96343e819841dcadbfeaa39b913f1dc45cb396ccdbb04c5f2278f9eb8
7
+ data.tar.gz: e65219591c790896c6bc36507678ec7168fe02dc963ac5e27375065047dc29d2e0ea11f2e10cf0e1853d779de21095ea34aa158d88d5b398f8b3320d50e5442d
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # LazyFind
2
2
 
3
+ ## Description
4
+
5
+ Simplified the first,last,take methods in ActiveRecord.So instead of using where and first, you can directly use first.
6
+
7
+
3
8
  ## Installation
4
9
 
5
10
  Add this line to your application's Gemfile:
@@ -18,7 +23,20 @@ Or install it yourself as:
18
23
 
19
24
  ## Usage
20
25
 
21
- TODO: Write usage instructions here
26
+ Simplified the first,last,take methods in ActiveRecord.
27
+
28
+ Find the first record (or first N records if a parameter is supplied).
29
+
30
+ Old Syntax:
31
+
32
+ Person.where(:email => "jenorish@gmail").first
33
+
34
+ New Syntax:
35
+
36
+ Person.first(:email => "jenorish@gmail")
37
+
38
+ # returns the first three objects fetched by SELECT * FROM people WHERE email= 'jenorish@gmail.com' ORDER BY people.id LIMIT 3
39
+
22
40
 
23
41
  ## Development
24
42
 
@@ -2,7 +2,7 @@ module LazyFind
2
2
  module ActiveRecord
3
3
  module FinderMethods
4
4
 
5
-
5
+ MAPPING = {:first => 0, :last => -1}
6
6
  # Find the first record (or first N records if a parameter is supplied).
7
7
  # If no order is defined it will order by primary key.
8
8
  #
@@ -56,12 +56,12 @@ module LazyFind
56
56
  private
57
57
 
58
58
  def lazy_find(attr,filter)
59
- case attr.class
60
- when Hash, Array, String
61
- where(attr).send(filter,nil)
59
+ if [Hash, Array, String].include?(attr.class)
60
+ result = where(attr).send(filter,nil)
62
61
  else
63
- send(filter,nil)
62
+ result = send(filter,nil)
64
63
  end
64
+ result
65
65
  end
66
66
 
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module LazyFind
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_find
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kingston