lazy_find 0.1.3 → 0.1.5

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: 482630265a7f13716c29823af19bfd8dc91a9527c838af71adb7b4c2c9e7b289
4
- data.tar.gz: b54f1b1ed641fc2051f41860a502f551230f0bc55ced0bad79ce9cddc18b7aeb
3
+ metadata.gz: 976ebc2609a7de85534e74f8d7cee02e7023819d7cc09f4effff81af82bf2d51
4
+ data.tar.gz: ba0944f4f578ee8c3bafe7dc3a8be95f9000f3868dd61ea083fbe376420080d2
5
5
  SHA512:
6
- metadata.gz: e73914d79e705dab96da19198b989dd0e41fdec37cdbae7985fc332fcc6e7c31ab900f830bdb65d6fc1fb679707d05e99d0fa73a757f3326fd07b7a581f87fd8
7
- data.tar.gz: aa2ee9fde37d963713bfab959a949fd6a19235d2aa9d8ecf9cc0815677962220083bfe8f141a8a119f14895c2ea5ee8d44dd4ab7866056c1edfe472a277d1e59
6
+ metadata.gz: 17d9e4b330a7881ca7771a104ad0b28cf15e0a00d7f17ed13190f22140aa04c2c411ec8ab6a7585467cbf8079601bc83fc0cd675226c496d6dc52abd08cd6d1b
7
+ data.tar.gz: b2894589577409993c57ac4a9d5e20a81bc29f4adcc7722f9accbb511cc39efabf71b7b4080f727fa64f4c98dc84fe4591ce2199001d4a7d1df1d21d8c0d98cd
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  Simplified the first,last,take methods in ActiveRecord.So instead of using where and first, you can directly use first.
6
6
 
7
7
 
8
+
8
9
  ## Installation
9
10
 
10
11
  Add this line to your application's Gemfile:
@@ -49,6 +50,15 @@ Or install it yourself as:
49
50
 
50
51
  Person.first(:email => "jenorish@gmail",:order => "created_at", select: [:name, :email])
51
52
 
53
+ ## New methods
54
+
55
+ We can use find all in lazy way by passing like below
56
+
57
+ Person.lazy_all(:email => "jenorish@gmail",:order => "created_at")
58
+
59
+ And support `Rails 3` where syntax
60
+
61
+ Person.lazy_where(:email => "jenorish@gmail",:order => "created_at")
52
62
 
53
63
 
54
64
  ## Development
@@ -53,6 +53,17 @@ module LazyFind
53
53
  lazy_find(attr,:take)
54
54
  end
55
55
 
56
+ # posts = Post.all
57
+ # posts.size # Fires "select count(*) from posts" and returns the count
58
+ # posts.each {|p| puts p.name } # Fires "select * from posts" and loads post objects
59
+
60
+ def lazy_all(attr = nil)
61
+ return all if attr.blank?
62
+ lazy_find(attr,:all)
63
+ end
64
+
65
+ alias_method :lazy_where, :lazy_all
66
+
56
67
  private
57
68
 
58
69
  def lazy_find(attr,filter)
@@ -60,9 +71,9 @@ module LazyFind
60
71
  sort_val = extract_order(attr)
61
72
  select_val = extract_select(attr)
62
73
  if select_val
63
- where(attr).order(sort_val).select(select_val).send(filter,nil)
74
+ where(attr).order(sort_val).select(select_val).send(filter)
64
75
  else
65
- where(attr).order(sort_val).send(filter,nil)
76
+ where(attr).order(sort_val).send(filter)
66
77
  end
67
78
  else
68
79
  send(filter,nil)
@@ -1,3 +1,3 @@
1
1
  module LazyFind
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kingston