recordx_sqlite 0.2.4 → 0.2.5

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
2
  SHA1:
3
- metadata.gz: 3b2d00491066a7d63ce46dbe194fa757f244906a
4
- data.tar.gz: 0df5082d48ee9800b3757a611162f5625f197b92
3
+ metadata.gz: 608b01a6d789ee7139213da5a65e9bd1160de9f5
4
+ data.tar.gz: a58cf47dce501b6cac28b030704832d339f3c867
5
5
  SHA512:
6
- metadata.gz: 552bffbd7e389b9f63f622e4b248f11fb7a02d6ec029f061e23baf81f0feeec1990e2ab6f9d9b57c23340afd21461ab957fa3f6a1d4d18b310261df4c85dc547
7
- data.tar.gz: f1396bdaeffcd57b9e595d740e8bf7d450c8d6f1a83408beea979d2530bf228f82c7e47fddcf39e6554f78b1f6b3484d3c8dc7fa3063106e4a5651e6880560a7
6
+ metadata.gz: b29579a30c0666b295b0c3de86331a4fc5b4f576ead42ac103c516976d565d13109c833110a32d743a528b8cc772844c427bfdc96e819a002ab916794c26b19f
7
+ data.tar.gz: 4209e323bfe6d09b5f86b0ae09bcec5f1fbdd0ed7f823d4f77a95db7732919487af23775fd333889db21c1a14b6ebe379f38a361b544ac34092f63537dd30e0e
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -53,7 +53,7 @@ class RecordxSqlite
53
53
 
54
54
  @db.execute(sql, values)
55
55
 
56
- :create
56
+ :create
57
57
  end
58
58
 
59
59
  def delete(id)
@@ -70,17 +70,26 @@ class RecordxSqlite
70
70
  @a.find {|x| x.method(@primary_key).call == id}
71
71
 
72
72
  end
73
+
74
+ # returns the 1st n rows
75
+ #
76
+ def first(n=1)
77
+ query(@sql + ' LIMIT ' + n.to_s, cache: false)
78
+ end
73
79
 
74
- def query(sql=@sql)
80
+ def query(sql=@sql, cache: true)
75
81
 
76
- @sql = sql
77
82
  rs = @db.query sql
78
83
 
79
- @a = rs.map do |h|
84
+ a = rs.map do |h|
80
85
  h2 = h.inject({}) {|r, x| k, v = x; r.merge(k.to_sym => v)}
81
86
  RecordX.new(h2, self, h2[@primary_key])
82
87
  end
83
88
 
89
+ @a = a if cache
90
+
91
+ return a
92
+
84
93
  end
85
94
 
86
95
  def refresh()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordx_sqlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  pewreBQ0QCPuPbV1FPlyX5N5qsGIMHFIYqUlaykOA8156Y6fbIbqQsLwxaSr8WkD
32
32
  eojajR/fTTvliw==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-07-01 00:00:00.000000000 Z
34
+ date: 2017-07-02 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
metadata.gz.sig CHANGED
Binary file