tiny-record 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +11 -2
- data/lib/tiny/record/version.rb +1 -1
- data/lib/tiny/record.rb +5 -1
- data/tiny-record.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9d27daa4f162a7810b594a110530209875a3a82
|
4
|
+
data.tar.gz: 7dd74f59d7430dceb79b65b4a43c830ab58416b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6f19d8dad6eb349f68261ad5a5ff889ffd2aa85a2129548261d0a2496bb717063e83a5b9238c5fbcbb34a0009224cff618bf56007511f60a4b2cd9008803d74
|
7
|
+
data.tar.gz: 04e05b735ac1ba82b87f06cd25bf0f31562998606d226169e78651e89d225e16cf8a146914ca4137130ce470acad3db5dbc163d83fcb012867b0e497b2c1c739
|
data/.travis.yml
CHANGED
@@ -4,4 +4,9 @@ language: ruby
|
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
6
|
- 2.3.6
|
7
|
-
before_install:
|
7
|
+
before_install:
|
8
|
+
- mysql -e 'CREATE DATABASE IF NOT EXISTS memory;'
|
9
|
+
- gem install bundler -v 1.16.3
|
10
|
+
services:
|
11
|
+
- mysql
|
12
|
+
if: branch = master OR type = 'pull_request'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
[![Build Status](https://travis-ci.com/vikasvr/tiny-record.svg?branch=master)](https://travis-ci.com/vikasvr/tiny-record)
|
2
|
+
|
1
3
|
# TinyRecord
|
2
4
|
|
3
5
|
TinyRecord gives to you the capability to target columns when you try to look for active record objects specifying the columns you want to use which gives you speed. Logic is simple, less the data you will ask for, faster database response would be.
|
4
6
|
|
5
|
-
|
6
|
-
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
@@ -40,6 +40,15 @@ Or install it yourself as:
|
|
40
40
|
```
|
41
41
|
Just like rails find_by, it will return nil when record not found.
|
42
42
|
|
43
|
+
You can also set defaults by:
|
44
|
+
```ruby
|
45
|
+
class User < ApplicationRecord
|
46
|
+
include TinyRecord
|
47
|
+
tiny_columns :id, :first_name
|
48
|
+
end
|
49
|
+
```
|
50
|
+
Now whenever you use fetch or fetch by method record will be returned with these default columns.
|
51
|
+
You can override these defaults by specifying the columns.
|
43
52
|
|
44
53
|
## Contributing
|
45
54
|
|
data/lib/tiny/record/version.rb
CHANGED
data/lib/tiny/record.rb
CHANGED
@@ -12,7 +12,7 @@ module TinyRecord
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def fetch(id, with: @@with_columns)
|
15
|
-
get(
|
15
|
+
get(primary_lookup(id), with).take!
|
16
16
|
end
|
17
17
|
|
18
18
|
def fetch_by(columns = {})
|
@@ -25,5 +25,9 @@ module TinyRecord
|
|
25
25
|
collection = collection.select(with_columns) if with_columns.present?
|
26
26
|
collection
|
27
27
|
end
|
28
|
+
|
29
|
+
def primary_lookup(lookup_id)
|
30
|
+
{ primary_key => lookup_id }
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
data/tiny-record.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata["allowed_push_host"] = '
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
21
|
# else
|
22
22
|
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
23
|
# "public gem pushes."
|
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:
|
4
|
+
version: 1.0.0
|
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-05-
|
11
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,7 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.6.14
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: target columns when querying for active record objects
|