tiny-record 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -2
- data/lib/tiny/record.rb +20 -7
- data/lib/tiny/record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42e47d71325853435439dc964b8f1d6e889d867dabe2a80f56136c7701875ce6
|
4
|
+
data.tar.gz: ea501b5d53d7f3f0b497a17f92130ad0cdd81f2a0696ac7875d303dc214347e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30eda518023db02caa9bdc0a051c628331897e4aa3a9012bff38debae6657276998aa233aa9c5b95912ce75943bfcb26c36a4391647ccb6d199d16d617d171e4
|
7
|
+
data.tar.gz: 3c26ef5a15c3a754e2c5acdb6903f1a090d53d5ca1005b55fecae2156326f75b1e6d2d2b10f650351fb26856d4b497e1c06bcd70a103e1847c2b7af20e4f2a05
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,22 @@
|
|
1
|
-
|
1
|
+
## 1.1.2 - 2020-01-02
|
2
2
|
|
3
|
-
|
3
|
+
### Improvements
|
4
|
+
|
5
|
+
* Now fetch_where supports string queries, for eg.
|
6
|
+
```ruby
|
7
|
+
User.fetch_where("first_name = ?", "John")
|
8
|
+
```
|
9
|
+
|
10
|
+
## 1.1.1 - 2019-12-30
|
11
|
+
|
12
|
+
### Bugfixes
|
13
|
+
|
14
|
+
* Fix tiny column's configuration not working when used in multiple classes.
|
15
|
+
|
16
|
+
|
17
|
+
## 1.0.3 - 2019-06-08
|
18
|
+
|
19
|
+
### Improvements
|
4
20
|
* Added fetch_where which can be used as :
|
5
21
|
```ruby
|
6
22
|
User.fetch_where(city: "london", with: [:first_name, :last_name])
|
data/lib/tiny/record.rb
CHANGED
@@ -13,17 +13,20 @@ module TinyRecord
|
|
13
13
|
_get_records(_primary_lookup(id), with).take!
|
14
14
|
end
|
15
15
|
|
16
|
-
def fetch_by(
|
17
|
-
with =
|
18
|
-
_get_records(
|
16
|
+
def fetch_by(tiny_columns = {})
|
17
|
+
with = tiny_columns.delete(:with)
|
18
|
+
_get_records(tiny_columns, with).take
|
19
19
|
end
|
20
20
|
|
21
|
-
def fetch_where(
|
22
|
-
|
23
|
-
|
21
|
+
def fetch_where(*args)
|
22
|
+
if args[0].is_a?(Hash)
|
23
|
+
_fetch_from_hash(args)
|
24
|
+
else
|
25
|
+
_fetch_from_string(args)
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
|
-
def _get_records(by_columns, with_columns)
|
29
|
+
def _get_records(by_columns, with_columns = nil)
|
27
30
|
collection = where(by_columns)
|
28
31
|
collection = _retrieve_selective_columns(collection,with_columns)
|
29
32
|
collection
|
@@ -35,6 +38,16 @@ module TinyRecord
|
|
35
38
|
collection
|
36
39
|
end
|
37
40
|
|
41
|
+
def _fetch_from_hash(args)
|
42
|
+
target_parameter = args[0]
|
43
|
+
with = target_parameter.delete(:with)
|
44
|
+
_get_records(target_parameter, with)
|
45
|
+
end
|
46
|
+
|
47
|
+
def _fetch_from_string(args)
|
48
|
+
_get_records(args)
|
49
|
+
end
|
50
|
+
|
38
51
|
def _default_tiny_columns
|
39
52
|
@default_tiny_columns
|
40
53
|
end
|
data/lib/tiny/record/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vikas Verma
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|