tiny-record 1.1.0 → 1.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
- SHA1:
3
- metadata.gz: bf57e4cc2dba1320f23fda494a6085e0b40d2192
4
- data.tar.gz: 3177fdbcdf79fc389e97a981f3aa0e993012c032
2
+ SHA256:
3
+ metadata.gz: bd7ba4e437f4589089876cd1c3865c4a9adb144cea14b884d60157d054b7a717
4
+ data.tar.gz: 2a6e1bd618b2235d1b747869eb5cff9c15c03ca399210140414c6cfc6187af61
5
5
  SHA512:
6
- metadata.gz: cf41984edc81a44d9c32b1dac2a1ac9e0f0917ed4e81a64f3def7df5105a058a5a706e3bd534df41b2ce8a3e4d250dda0fa80c34e662f864d722f66f14fe8ed6
7
- data.tar.gz: b804c658986dd30f9669c76cb1fe491a0fbfa737560da194d232e838897f658a1a8a9a14720df9f93dda32aed574cb619ab59700017b7987aac370d15fab25f0
6
+ metadata.gz: f010a41b376356af14238cb677afa499a2b0bd2fb617d7b16e092c2e1f9005e05aec03dac57d56358c96b571da07054031c21e1f1045ded90be2e66af3419903
7
+ data.tar.gz: da4fb982ad5f2a37cc295bb042e5eb0dae37458fd76d675dcac9a644c3b0ac425f835f7e494e8d2b6e9e9741a049cf2633efa5adb8563c2883dea65e177cbdae
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tiny-record (1.1.0)
4
+ tiny-record (1.1.1)
5
5
  activerecord (>= 4.0)
6
6
 
7
7
  GEM
data/lib/tiny/record.rb CHANGED
@@ -1,37 +1,45 @@
1
1
  require "tiny/record/version"
2
-
3
2
  module TinyRecord
4
3
  def self.included(base)
5
4
  base.extend ClassMethods
6
5
  end
7
6
  module ClassMethods
8
- @@with_columns = []
9
7
 
10
8
  def tiny_columns(*args)
11
- @@with_columns = *args
9
+ @default_tiny_columns = *args
12
10
  end
13
11
 
14
- def fetch(id, with: @@with_columns)
15
- get(primary_lookup(id), with).take!
12
+ def fetch(id, with: nil)
13
+ _get_records(_primary_lookup(id), with).take!
16
14
  end
17
15
 
18
16
  def fetch_by(columns = {})
19
17
  with = columns.delete(:with)
20
- get(columns, with).take
18
+ _get_records(columns, with).take
21
19
  end
22
20
 
23
21
  def fetch_where(columns = {})
24
22
  with = columns.delete(:with)
25
- get(columns, with)
23
+ _get_records(columns, with)
26
24
  end
27
25
 
28
- def get(by_columns, with_columns)
26
+ def _get_records(by_columns, with_columns)
29
27
  collection = where(by_columns)
30
- collection = collection.select(with_columns) if with_columns.present?
28
+ collection = _retrieve_selective_columns(collection,with_columns)
29
+ collection
30
+ end
31
+
32
+ def _retrieve_selective_columns(collection, requested_columns)
33
+ target_columns = requested_columns && requested_columns.present? ? requested_columns : _default_tiny_columns
34
+ collection = collection.select(target_columns) if collection.present?
31
35
  collection
32
36
  end
33
37
 
34
- def primary_lookup(lookup_id)
38
+ def _default_tiny_columns
39
+ @default_tiny_columns
40
+ end
41
+
42
+ def _primary_lookup(lookup_id)
35
43
  { primary_key => lookup_id }
36
44
  end
37
45
  end
@@ -1,5 +1,5 @@
1
1
  module Tiny
2
2
  module Record
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
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.0
4
+ version: 1.1.1
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-06-08 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.6.14
139
+ rubygems_version: 3.0.6
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: target columns when querying for active record objects