tiny-record 1.1.1 → 1.1.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd7ba4e437f4589089876cd1c3865c4a9adb144cea14b884d60157d054b7a717
4
- data.tar.gz: 2a6e1bd618b2235d1b747869eb5cff9c15c03ca399210140414c6cfc6187af61
3
+ metadata.gz: 42e47d71325853435439dc964b8f1d6e889d867dabe2a80f56136c7701875ce6
4
+ data.tar.gz: ea501b5d53d7f3f0b497a17f92130ad0cdd81f2a0696ac7875d303dc214347e3
5
5
  SHA512:
6
- metadata.gz: f010a41b376356af14238cb677afa499a2b0bd2fb617d7b16e092c2e1f9005e05aec03dac57d56358c96b571da07054031c21e1f1045ded90be2e66af3419903
7
- data.tar.gz: da4fb982ad5f2a37cc295bb042e5eb0dae37458fd76d675dcac9a644c3b0ac425f835f7e494e8d2b6e9e9741a049cf2633efa5adb8563c2883dea65e177cbdae
6
+ metadata.gz: 30eda518023db02caa9bdc0a051c628331897e4aa3a9012bff38debae6657276998aa233aa9c5b95912ce75943bfcb26c36a4391647ccb6d199d16d617d171e4
7
+ data.tar.gz: 3c26ef5a15c3a754e2c5acdb6903f1a090d53d5ca1005b55fecae2156326f75b1e6d2d2b10f650351fb26856d4b497e1c06bcd70a103e1847c2b7af20e4f2a05
@@ -1,6 +1,22 @@
1
- ### 1.0.3 - 2019-06-08
1
+ ## 1.1.2 - 2020-01-02
2
2
 
3
- * Enhancements
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])
@@ -13,17 +13,20 @@ module TinyRecord
13
13
  _get_records(_primary_lookup(id), with).take!
14
14
  end
15
15
 
16
- def fetch_by(columns = {})
17
- with = columns.delete(:with)
18
- _get_records(columns, with).take
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(columns = {})
22
- with = columns.delete(:with)
23
- _get_records(columns, with)
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
@@ -1,5 +1,5 @@
1
1
  module Tiny
2
2
  module Record
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
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.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: 2019-12-30 00:00:00.000000000 Z
11
+ date: 2020-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler