xquery 0.1.3-java → 0.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xquery/abstract.rb +28 -12
- data/lib/xquery/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7805222ef90fd9a6a76f3c4cd21783e438a026d0
|
4
|
+
data.tar.gz: c2bcff3ecf1a549f62a32cdfa9270aac3f4f03f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7fc897c36eec97a269b8502a9664a776347c1cdea2c5a64b429683fd87e0f7725927e456ba3eca4d53aadb6ba6319ccbda523c3a14cbd154d25d5a98ca6ef86
|
7
|
+
data.tar.gz: bb8e5ef86fc5cd94ce53415fe3c8fbd86263bed4e2363a754491619860a261de9bd399e1779dd6e136244567d7ddd2dabdcb60c6d62ccfb0b95751c24c916d88
|
data/lib/xquery/abstract.rb
CHANGED
@@ -4,11 +4,11 @@ require 'xquery/query_proxy'
|
|
4
4
|
require 'xquery/errors'
|
5
5
|
|
6
6
|
module XQuery
|
7
|
-
#
|
7
|
+
# Abstract superclass, should be inherited, not used
|
8
8
|
class Abstract
|
9
9
|
class_attribute :query_superclass
|
10
10
|
|
11
|
-
#
|
11
|
+
# Yields instance inside block. I suggest to name it `q`
|
12
12
|
# @param args [Array(Object)] array of arguments would be passed to
|
13
13
|
# @param block [#to_proc] block to witch instance would be yielded
|
14
14
|
def self.with(*args, &block)
|
@@ -17,10 +17,6 @@ module XQuery
|
|
17
17
|
instance.query
|
18
18
|
end
|
19
19
|
|
20
|
-
class << self
|
21
|
-
alias_method :execute, :with
|
22
|
-
end
|
23
|
-
|
24
20
|
# Defines `method`, `__method` and `q.method`.
|
25
21
|
# Both of wich changes query to query.method
|
26
22
|
# @param name [#to_sym] name of method on query
|
@@ -30,13 +26,13 @@ module XQuery
|
|
30
26
|
alias_on_q(as, true)
|
31
27
|
end
|
32
28
|
|
33
|
-
#
|
29
|
+
# Aame as wrap_method, but hanldes multiply methods
|
34
30
|
# @param methods [Array(#to_sym)] names of methods defined
|
35
31
|
def self.wrap_methods(*methods)
|
36
32
|
methods.each(&method(:wrap_method))
|
37
33
|
end
|
38
34
|
|
39
|
-
# Aliases method to __method and q.method
|
35
|
+
# Aliases method to `#__method` and `q.method`
|
40
36
|
# @param name [#to_sym] name of method
|
41
37
|
# @param return_self [Boolean] should defined method return self or result
|
42
38
|
def self.alias_on_q(name, return_self = false)
|
@@ -68,7 +64,27 @@ module XQuery
|
|
68
64
|
@query_proxy = self.class.query_proxy.new(self)
|
69
65
|
end
|
70
66
|
|
71
|
-
#
|
67
|
+
# Yields iteself inside block. I suggest to name it `q`
|
68
|
+
# @param block [#to_proc] block to whitch instance would be yielded
|
69
|
+
# @return [Object] query
|
70
|
+
def with(&block)
|
71
|
+
block.call(self)
|
72
|
+
query
|
73
|
+
end
|
74
|
+
|
75
|
+
# Executes specified method, returns query.
|
76
|
+
# Feel free to redefine this method in case it's only public api method
|
77
|
+
# in your class
|
78
|
+
# @param method [#to_sym] any instance public method name
|
79
|
+
# @param args [Array(Object)] method call params
|
80
|
+
# @param block [#to_proc] block would be sent to method
|
81
|
+
# @return [Object] query
|
82
|
+
def execute(method, *args, &block)
|
83
|
+
public_send(method, *args, &block)
|
84
|
+
query
|
85
|
+
end
|
86
|
+
|
87
|
+
# Yields query inside block
|
72
88
|
# @param block [#to_proc]
|
73
89
|
# @return [XQuery::Abstract] self
|
74
90
|
def apply(&block)
|
@@ -78,14 +94,14 @@ module XQuery
|
|
78
94
|
|
79
95
|
private
|
80
96
|
|
81
|
-
#
|
82
|
-
#
|
97
|
+
# Private Api!
|
98
|
+
# Updates query by calling method on it and storing the result
|
83
99
|
# @return [XQuery::Abstract] self
|
84
100
|
def _update_query(method, *args, &block)
|
85
101
|
apply { |x| x.public_send(method, *args, &block) }
|
86
102
|
end
|
87
103
|
|
88
|
-
#
|
104
|
+
# Added constraints check
|
89
105
|
# @raise XQuery::QuerySuperclassChanged
|
90
106
|
def query=(x)
|
91
107
|
unless x.is_a?(query_superclass)
|
data/lib/xquery/version.rb
CHANGED