basic-scopes 0.1.2 → 0.1.3

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
- MmU3ZjU5ODRmZDQ4YWY1MmQyOGJkOGEyYTIyNmUxMzI5MWQzZmFhZg==
4
+ NTU1YTUyMWQ4MjM1ZmJjYjUyNzk3MTg5ZGI2NWU5MjNjNTIzYzA4ZA==
5
5
  data.tar.gz: !binary |-
6
- MGJiZDA1Y2E1ZjY5NzVmMGFmNGUzYjAwNDg4YWU1OWEwY2Q5Y2I4ZA==
6
+ NzlhYTk1NzFmMjUwYmE4Y2VjMTgxNzY2NDY0NDZjOTk2NzM3ZjNmMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGI4ZGMyZjY5ZjFiYmEyNDJjYzUwZjE2OWJiMzBmZmI3OWVhNzBkMjEwNzIw
10
- ZjQwOTM4ZjljOTRkY2NjOTExYTdjY2YyNjkxM2EyYjAxOTczNmEwM2QyNDE2
11
- OTU2YzVlNjRlOGRlNDhkMTI2ZTJlYzBmYjA0YWNlYzhkYTMyODk=
9
+ OWFlYmRlMGMzNTE5NDRmMDk1YzZkM2MxYTdiMmYxNmRmOWIxYTcwOGUwNzk4
10
+ M2NjNmNlM2UxMjRlYTdlNTNiYTdjMjAzMWNiNjBkMWI2ZDg4NGY1ZGIyMTdm
11
+ NTMwNDMwNTEyN2I2ZmFiOWU0OTRhZmQ4ZDlkMTdhZTI3N2JlZjM=
12
12
  data.tar.gz: !binary |-
13
- NGY1ZmUyYzE3NDg5ZjZjNzNjMWI4YjhkN2JmYzY2YmE2M2JjMTY3NDc2OTc0
14
- MjQwNDVhNzI0YmJmMjI1NGMyOTFhMzA0NmFmYWNiOWI1N2UxYjVhY2YwODNh
15
- MWJjMGRjOGU1MGRlNTRmN2RkNjAxZTkzY2EyNTk3YzMzMjI5YTE=
13
+ NGMxZGE3NmI2NzdjNDg3YmI4OTA5ODRlYzYzOTgzZTgzMTgyZjE1ZDdiZjcx
14
+ ODZiODcwM2Q3NzgzZjBlOGU3MDVlYzFlZTQ3MDhhNWQyODRkMzc0M2ZkNzQ3
15
+ MGZiZDljZGM3ZDEwZjI4YzVmMmYyNjU2YTU5ODZkNzlmMmYxYzY=
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  ## basic-scopes
2
+ [![Gem Version](https://badge.fury.io/rb/basic-scopes.png)](http://badge.fury.io/rb/basic-scopes)
2
3
  [![Build Status](https://travis-ci.org/vforge/basic-scopes.png)](https://travis-ci.org/vforge/basic-scopes)
3
4
  [![Dependency Status](https://gemnasium.com/vforge/basic-scopes.png)](https://gemnasium.com/vforge/basic-scopes)
4
5
  [![Code Climate](https://codeclimate.com/github/vforge/basic-scopes.png)](https://codeclimate.com/github/vforge/basic-scopes)
6
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/vforge/basic-scopes/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
5
7
 
6
8
  ActiveRecord basic scopes.
7
9
 
@@ -10,6 +12,8 @@ ActiveRecord basic scopes.
10
12
  You can use basic-scopes just as normal ActiveRecord methods.
11
13
 
12
14
  ### Filtering
15
+ * `except_id(id)` - all records without matching `ID` field
16
+ * `filter_id(id)` - all recorth with matching `ID` field
13
17
  * `except_ids(ids)` - all records without matching `ID` field
14
18
  * `filter_ids(ids)` - all recorth with matching `ID` field
15
19
  * `filter_updated_since(time)` - all records that have `UPDATED_AT` field greater than `time`
@@ -18,7 +22,8 @@ You can use basic-scopes just as normal ActiveRecord methods.
18
22
  * `filter_created_till(time)` - all records that have `CREATED_AT` field lesser than `time`
19
23
 
20
24
 
21
- **NOTE**: `ids` param can be single `ID` or Array of `ID`s
25
+ **NOTE**: `ids` param is an Array of `ID`s; `id` is single value
26
+
22
27
 
23
28
  ### Sorting / OrderBy
24
29
  * `by_id` - order by `ID` descending
@@ -28,10 +33,10 @@ You can use basic-scopes just as normal ActiveRecord methods.
28
33
  * `by_updated_at` - order by `UPDATED_AT` descending
29
34
  * `by_updated_at_reversed` - order by `UPDATED_AT` ascending
30
35
 
31
- ## Example
36
+ ## Examples
32
37
 
33
- `User.filter_last_update(1.day).by_updated_at` - All users updated in the last one day, ordered by time
38
+ `Account.except_id(1)` - All Accounts except ID == 1.
39
+ `User.filter_updated_since(1.day).by_updated_at` - All Users updated in the last one day, ordered by time
34
40
 
35
41
 
36
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/vforge/basic-scopes/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
37
42
 
@@ -1,3 +1,3 @@
1
1
  module BasicScopes
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/basic-scopes.rb CHANGED
@@ -8,6 +8,14 @@ module BasicScopes
8
8
 
9
9
  included do
10
10
  class << self
11
+ def except_id(id)
12
+ self.where("#{self.table_name}.id <> ?", id)
13
+ end
14
+
15
+ def filter_id(id)
16
+ self.where("#{self.table_name}.id = ?", id)
17
+ end
18
+
11
19
  def except_ids(ids)
12
20
  self.where("#{self.table_name}.id NOT IN (?)", ids)
13
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basic-scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz "V." Bentkowski