native-query 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "fluent-query", ">= 0.9.0"
4
+ gem "fluent-query", ">= 0.9.1"
5
5
  gem "hash-utils", ">= 0.18.0"
6
+ gem "lookup-hash", ">= 0.2.0"
6
7
 
7
8
  # Add dependencies to develop your gem here.
8
9
  # Include everything needed to run rake, tests, features, etc.
@@ -2,7 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- fluent-query (0.9.0)
5
+ fluent-query (0.9.1)
6
6
  abstract (>= 1.0.0)
7
7
  hash-utils (>= 0.18.0)
8
8
  hashie (>= 1.0.0)
@@ -13,6 +13,8 @@ GEM
13
13
  bundler (~> 1.0)
14
14
  git (>= 1.2.5)
15
15
  rake
16
+ lookup-hash (0.2.0)
17
+ hash-utils (>= 0.11.0)
16
18
  rake (0.9.2)
17
19
 
18
20
  PLATFORMS
@@ -20,6 +22,7 @@ PLATFORMS
20
22
 
21
23
  DEPENDENCIES
22
24
  bundler (~> 1.0.13)
23
- fluent-query (>= 0.9.0)
25
+ fluent-query (>= 0.9.1)
24
26
  hash-utils (>= 0.18.0)
25
27
  jeweler (~> 1.6.0)
28
+ lookup-hash (>= 0.2.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -1,6 +1,8 @@
1
1
  # encoding: utf-8
2
2
  require "fluent-query/connection"
3
3
  require "native-query/query"
4
+ require "hash-utils/object"
5
+ require "lookup-hash"
4
6
 
5
7
  module NativeQuery
6
8
 
@@ -10,6 +12,15 @@ module NativeQuery
10
12
 
11
13
  class Model
12
14
 
15
+ ##
16
+ # Indicates relevant methods for binding to the
17
+ # connection object.
18
+ #
19
+
20
+ RELEVANT_METHODS = LookupHash[
21
+ :insert, :update, :delete, :begin, :commit, :rollback, :transaction
22
+ ]
23
+
13
24
  ##
14
25
  # Brings database connection object.
15
26
  #
@@ -57,19 +68,28 @@ module NativeQuery
57
68
  #
58
69
 
59
70
  def method_missing(sym, *args, &block)
60
- query = Query::new(self.connection, sym)
61
71
 
62
- if args and not args.empty?
63
- query.fields(*args)
64
- end
65
-
66
- if block
67
- result = query.instance_eval(&block)
72
+ # If it's binding to the connection
73
+ if sym.in? Model::RELEVANT_METHODS
74
+ return self.connection.send(sym, *args, &block)
75
+
76
+ # In otherwise, it's query request
68
77
  else
69
- result = query
70
- end
78
+ query = Query::new(self.connection, sym)
79
+
80
+ if args and not args.empty?
81
+ query.fields(*args)
82
+ end
83
+
84
+ if not block.nil?
85
+ result = query.instance_eval(&block)
86
+ else
87
+ result = query
88
+ end
71
89
 
72
- return result
90
+ return result
91
+ end
92
+
73
93
  end
74
94
 
75
95
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{native-query}
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Martin Kozák}]
@@ -40,19 +40,22 @@ Gem::Specification.new do |s|
40
40
  s.specification_version = 3
41
41
 
42
42
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
- s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.0"])
43
+ s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.1"])
44
44
  s.add_runtime_dependency(%q<hash-utils>, [">= 0.18.0"])
45
+ s.add_runtime_dependency(%q<lookup-hash>, [">= 0.2.0"])
45
46
  s.add_development_dependency(%q<bundler>, ["~> 1.0.13"])
46
47
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
47
48
  else
48
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
49
+ s.add_dependency(%q<fluent-query>, [">= 0.9.1"])
49
50
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
51
+ s.add_dependency(%q<lookup-hash>, [">= 0.2.0"])
50
52
  s.add_dependency(%q<bundler>, ["~> 1.0.13"])
51
53
  s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
52
54
  end
53
55
  else
54
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
56
+ s.add_dependency(%q<fluent-query>, [">= 0.9.1"])
55
57
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
58
+ s.add_dependency(%q<lookup-hash>, [">= 0.2.0"])
56
59
  s.add_dependency(%q<bundler>, ["~> 1.0.13"])
57
60
  s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
58
61
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: native-query
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.0
5
+ version: 0.9.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Martin Koz\xC3\xA1k"
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.9.0
22
+ version: 0.9.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: *id001
@@ -35,8 +35,19 @@ dependencies:
35
35
  prerelease: false
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
- name: bundler
38
+ name: lookup-hash
39
39
  requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.2.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: &id004 !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ~>
@@ -44,10 +55,10 @@ dependencies:
44
55
  version: 1.0.13
45
56
  type: :development
46
57
  prerelease: false
47
- version_requirements: *id003
58
+ version_requirements: *id004
48
59
  - !ruby/object:Gem::Dependency
49
60
  name: jeweler
50
- requirement: &id004 !ruby/object:Gem::Requirement
61
+ requirement: &id005 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ~>
@@ -55,7 +66,7 @@ dependencies:
55
66
  version: 1.6.0
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *id004
69
+ version_requirements: *id005
59
70
  description:
60
71
  email: martinkozak@martinkozak.net
61
72
  executables: []
@@ -92,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
103
  requirements:
93
104
  - - ">="
94
105
  - !ruby/object:Gem::Version
95
- hash: 1037557380294456007
106
+ hash: 1488910724387024104
96
107
  segments:
97
108
  - 0
98
109
  version: "0"