predefined 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/predefined/query.rb +13 -8
- data/lib/predefined/sequel.rb +12 -4
- data/lib/predefined/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b447ed9143943b32a85bc61942c469f48458216
|
4
|
+
data.tar.gz: a1b5d2ce94527b12a412cd9bf795f895984a4294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39da7744234a43bf30925730be51809e1648c0cfa3b78875d045fa79270705b5e2a1485b522f65f9f07aba033b2b7ff3d0a091aa4269dc9516c1fa8dac7ee507
|
7
|
+
data.tar.gz: 65ace12c713ed0caf6fd63e3eadc096d969a51b14d6b1c34307be8c8c2cf74d747993900239993761cc44dce479cd082fbb4a7d1bb8bae81dcbad8134c6128a9
|
data/lib/predefined/query.rb
CHANGED
@@ -46,8 +46,9 @@ module Predefined
|
|
46
46
|
sql.to_s.split(/\n/).map(&:strip).join(' ')
|
47
47
|
end
|
48
48
|
|
49
|
-
def initialize(name)
|
49
|
+
def initialize(name, options={})
|
50
50
|
@name = name
|
51
|
+
@options = options
|
51
52
|
end
|
52
53
|
|
53
54
|
def template
|
@@ -60,32 +61,36 @@ module Predefined
|
|
60
61
|
raise "Not Implemented"
|
61
62
|
end
|
62
63
|
|
64
|
+
def predefined_helper_query(template_name)
|
65
|
+
predefined_helper_query_class.new(template_name)
|
66
|
+
end
|
67
|
+
|
63
68
|
def select_all(template_name, params=nil)
|
64
|
-
|
69
|
+
predefined_helper_query(template_name).select_all(params)
|
65
70
|
end
|
66
71
|
|
67
72
|
def select_one(template_name, params=nil)
|
68
|
-
|
73
|
+
predefined_helper_query(template_name).select_one(params)
|
69
74
|
end
|
70
75
|
|
71
76
|
def select_rows(template_name, params=nil)
|
72
|
-
|
77
|
+
predefined_helper_query(template_name).select_rows(params)
|
73
78
|
end
|
74
79
|
|
75
80
|
def select_values(template_name, params=nil)
|
76
|
-
|
81
|
+
predefined_helper_query(template_name).select_values(params)
|
77
82
|
end
|
78
83
|
|
79
84
|
def select_value(template_name, params=nil)
|
80
|
-
|
85
|
+
predefined_helper_query(template_name).select_value(params)
|
81
86
|
end
|
82
87
|
|
83
88
|
def select_object(template_name, klass, params=nil)
|
84
|
-
|
89
|
+
predefined_helper_query(template_name).select_object(klass, params)
|
85
90
|
end
|
86
91
|
|
87
92
|
def select_objects(template_name, klass, params=nil)
|
88
|
-
|
93
|
+
predefined_helper_query(template_name).select_objects(klass, params)
|
89
94
|
end
|
90
95
|
end
|
91
96
|
end
|
data/lib/predefined/sequel.rb
CHANGED
@@ -2,16 +2,24 @@ require 'predefined/query'
|
|
2
2
|
|
3
3
|
module Predefined
|
4
4
|
class SequelQuery < Query
|
5
|
+
def db
|
6
|
+
@options[:db]
|
7
|
+
end
|
8
|
+
|
9
|
+
def dataset(params=nil)
|
10
|
+
db.fetch(template, params || {})
|
11
|
+
end
|
12
|
+
|
5
13
|
def to_sql(params=nil)
|
6
|
-
|
14
|
+
dataset(params).sql
|
7
15
|
end
|
8
16
|
|
9
17
|
def select_all(params=nil)
|
10
|
-
|
18
|
+
dataset(params).all
|
11
19
|
end
|
12
20
|
|
13
21
|
def select_one(params=nil)
|
14
|
-
|
22
|
+
dataset(params).first
|
15
23
|
end
|
16
24
|
|
17
25
|
def select_rows(params=nil)
|
@@ -23,7 +31,7 @@ module Predefined
|
|
23
31
|
end
|
24
32
|
|
25
33
|
def select_value(params=nil)
|
26
|
-
|
34
|
+
dataset(params).get
|
27
35
|
end
|
28
36
|
|
29
37
|
def select_object(klass, params=nil)
|
data/lib/predefined/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predefined
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|