querier 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/README.md +22 -1
- data/lib/querier.rb +4 -2
- 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: 8b2d11506c653fd02680d9410d0e0bbb7b75f24b
|
4
|
+
data.tar.gz: 6c5dd58c5c86529e66e4d8974ac2ebb0db6b69eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688be4a3c50af9a55923f8d33b3e7440c7f09db8b1dccfc9db1a04835304dbdf91e7848a234e2484cc15f6fb4ee89ee81446c2a2e371fb82d30130d9d4cdbe90
|
7
|
+
data.tar.gz: c556a3a85323b67e81c729bf622016fdc637bfd7e7c1661067f18a70b07d855846f9dc35214c139c55560bb18d045cfcc2833520913f785a74e0c9960d764a1d
|
data/README.md
CHANGED
@@ -1 +1,22 @@
|
|
1
|
-
# querier
|
1
|
+
# querier
|
2
|
+
|
3
|
+
# class UserQuerier < Querier
|
4
|
+
QUERY_TEMPLATE = <<-END_OF_QUERY_TEMPLATE
|
5
|
+
|
6
|
+
SELECT
|
7
|
+
*
|
8
|
+
FROM
|
9
|
+
users
|
10
|
+
WHERE
|
11
|
+
name = {?user_name}
|
12
|
+
AND active = {?active}
|
13
|
+
|
14
|
+
END_OF_QUERY_TEMPLATE
|
15
|
+
|
16
|
+
def initialize user_name:, active:
|
17
|
+
@query_template = QUERY_TEMPLATE
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# UserQuerier.new(user_name: foo, active: true).execute
|
data/lib/querier.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Querier
|
2
|
+
PARAM_NAME_INDEX = 0
|
3
|
+
PARAM_VALUE_INDEX = 1
|
2
4
|
attr_reader :query_template, :query_params
|
3
5
|
|
4
6
|
def initialize **template_query_params
|
@@ -30,8 +32,8 @@ class Querier
|
|
30
32
|
query = query_template.dup
|
31
33
|
|
32
34
|
query_params.each do |query_param|
|
33
|
-
query_param_name = query_param[
|
34
|
-
query_param_value = query_param[
|
35
|
+
query_param_name = query_param[PARAM_NAME_INDEX].to_s
|
36
|
+
query_param_value = query_param[PARAM_VALUE_INDEX].class.eql?(String) ? "'#{query_param[PARAM_VALUE_INDEX].to_s}'" : query_param[PARAM_VALUE_INDEX].to_s
|
35
37
|
|
36
38
|
query.gsub! /{\?#{query_param_name}}/, query_param_value
|
37
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: querier
|
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
|
- Gedean Dias
|
@@ -30,7 +30,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.0.0
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - ">="
|