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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d326c7094088f2bd75bca4da0142c213c9a17ce
4
- data.tar.gz: 6d85ccf0c4bc7a30e3db7c177761e0445fc307a8
3
+ metadata.gz: 8b447ed9143943b32a85bc61942c469f48458216
4
+ data.tar.gz: a1b5d2ce94527b12a412cd9bf795f895984a4294
5
5
  SHA512:
6
- metadata.gz: 380223845dadba62611409069b8e155c262b713271dee3287e9c2d68561c55d456d8b621e8cd78a0e951b4bbd3aed13fa1aee7c24387da1e809cb9d23ba44ae3
7
- data.tar.gz: 937d20bc196b89fabcd6066281b6fb4103bd2d83f1a75d6487fe62f7ef9d06ab70d99e928f02a53f7dc102b9af088d5cc6d131b2b6a95639aee4ef1802cc7887
6
+ metadata.gz: 39da7744234a43bf30925730be51809e1648c0cfa3b78875d045fa79270705b5e2a1485b522f65f9f07aba033b2b7ff3d0a091aa4269dc9516c1fa8dac7ee507
7
+ data.tar.gz: 65ace12c713ed0caf6fd63e3eadc096d969a51b14d6b1c34307be8c8c2cf74d747993900239993761cc44dce479cd082fbb4a7d1bb8bae81dcbad8134c6128a9
@@ -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
- predefined_helper_query_class.new(template_name).select_all(params)
69
+ predefined_helper_query(template_name).select_all(params)
65
70
  end
66
71
 
67
72
  def select_one(template_name, params=nil)
68
- predefined_helper_query_class.new(template_name).select_one(params)
73
+ predefined_helper_query(template_name).select_one(params)
69
74
  end
70
75
 
71
76
  def select_rows(template_name, params=nil)
72
- predefined_helper_query_class.new(template_name).select_rows(params)
77
+ predefined_helper_query(template_name).select_rows(params)
73
78
  end
74
79
 
75
80
  def select_values(template_name, params=nil)
76
- predefined_helper_query_class.new(template_name).select_values(params)
81
+ predefined_helper_query(template_name).select_values(params)
77
82
  end
78
83
 
79
84
  def select_value(template_name, params=nil)
80
- predefined_helper_query_class.new(template_name).select_value(params)
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
- predefined_helper_query_class.new(template_name).select_object(klass, params)
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
- predefined_helper_query_class.new(template_name).select_objects(klass, params)
93
+ predefined_helper_query(template_name).select_objects(klass, params)
89
94
  end
90
95
  end
91
96
  end
@@ -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
- raise "TODO: Implement Me"
14
+ dataset(params).sql
7
15
  end
8
16
 
9
17
  def select_all(params=nil)
10
- raise "TODO: Implement Me"
18
+ dataset(params).all
11
19
  end
12
20
 
13
21
  def select_one(params=nil)
14
- raise "TODO: Implement Me"
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
- raise "TODO: Implement Me"
34
+ dataset(params).get
27
35
  end
28
36
 
29
37
  def select_object(klass, params=nil)
@@ -1,3 +1,3 @@
1
1
  module Predefined
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-01 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler