active-orient 0.6 → 0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/Gemfile +4 -10
  4. data/Guardfile +4 -12
  5. data/README.md +198 -261
  6. data/VERSION +1 -1
  7. data/active-orient-0.4.gem +0 -0
  8. data/active-orient-0.41.gem +0 -0
  9. data/active-orient.gemspec +5 -6
  10. data/config/boot.rb +0 -84
  11. data/config/connect.yml +4 -8
  12. data/examples/books.rb +39 -86
  13. data/examples/streets.rb +84 -85
  14. data/lib/active-orient.rb +9 -57
  15. data/lib/base.rb +145 -172
  16. data/lib/base_properties.rb +44 -40
  17. data/lib/model.rb +468 -0
  18. data/lib/orient.rb +60 -114
  19. data/lib/query.rb +73 -71
  20. data/lib/rest.rb +1059 -0
  21. data/lib/support.rb +319 -386
  22. data/test.rb +4 -0
  23. data/usecase.md +91 -0
  24. metadata +20 -65
  25. data/bin/active-orient-console +0 -38
  26. data/config/config.yml +0 -10
  27. data/create_project +0 -19
  28. data/examples/test_commands.rb +0 -92
  29. data/examples/test_commands_2.rb +0 -54
  30. data/examples/test_commands_3.rb +0 -48
  31. data/examples/test_commands_4.rb +0 -28
  32. data/examples/time_graph.md +0 -162
  33. data/gratefuldeadconcerts.md +0 -94
  34. data/lib/class_utils.rb +0 -300
  35. data/lib/database_utils.rb +0 -106
  36. data/lib/init.rb +0 -45
  37. data/lib/java-api.rb +0 -437
  38. data/lib/jdbc.rb +0 -211
  39. data/lib/model/edge.rb +0 -55
  40. data/lib/model/model.rb +0 -91
  41. data/lib/model/the_class.rb +0 -500
  42. data/lib/model/the_record.rb +0 -322
  43. data/lib/model/vertex.rb +0 -136
  44. data/lib/orientdb_private.rb +0 -48
  45. data/lib/other.rb +0 -330
  46. data/lib/rest/change.rb +0 -137
  47. data/lib/rest/create.rb +0 -488
  48. data/lib/rest/delete.rb +0 -134
  49. data/lib/rest/operations.rb +0 -160
  50. data/lib/rest/read.rb +0 -150
  51. data/lib/rest/rest.rb +0 -112
  52. data/lib/rest_disabled.rb +0 -24
  53. data/linkmap.md +0 -75
  54. data/namespace.md +0 -111
  55. data/old_lib_functions/two_general_class.rb +0 -139
  56. data/rails.md +0 -125
  57. data/rails/activeorient.rb +0 -53
  58. data/rails/config.yml +0 -10
  59. data/rails/connect.yml +0 -17
  60. data/usecase_oo.md +0 -61
@@ -1,439 +1,372 @@
1
- require 'active_support/inflector'
2
- module OrientSupport
3
- module Support
4
-
5
- =begin
6
- supports
7
- where: 'string'
8
- where: { property: 'value', property: value, ... }
9
- where: ['string, { property: value, ... }, ... ]
10
- Used by update and select
11
- =end
12
-
13
- ## ORD.compose_where 'z=34', {u:6}
14
- # => "where z=34 and u = 6"
15
- #
16
- def compose_where *arg
17
- arg = arg.flatten
18
- return "" if arg.blank? || arg.size == 1 && arg.first.blank?
19
- "where " + arg.map do |issue|
20
- case issue
21
- when String
22
- issue
23
- else
24
- generate_sql_list issue
25
- end
26
- end.join(' and ')
27
- end
28
-
29
- =begin
30
- designs a list of "Key = Value" pairs combined by "and" or the fillword provided by the block
31
- ORD.generate_sql_list where: 25 , upper: '65'
32
- => "where = 25 and upper = '65'"
33
- ORD.generate_sql_list( con_id: 25 , symbol: :G) { ',' }
34
- => "con_id = 25 , symbol = 'G'"
35
- =end
36
- def generate_sql_list attributes = {}
37
- fill = block_given? ? yield : 'and'
38
- attributes.map do |key, value|
39
- case value
40
- when ActiveOrient::Model
41
- "#{key} = #{value.rrid}"
42
- when Numeric
43
- "#{key} = #{value}"
44
- when ::Array
45
- "#{key} in [#{value.to_orient}]"
46
- when Range
47
- "#{key} between #{value.first} and #{value.last} "
48
- when DateTime
49
- "#{key} = date(\'#{value.strftime("%Y%m%d%H%M%S")}\',\'yyyyMMddHHmmss\')"
50
- when Date
51
- "#{key} = date(\'#{value.to_s}\',\'yyyy-MM-dd\')"
52
- else # String, Symbol, Time, Trueclass, Falseclass ...
53
- "#{key} = \'#{value.to_s}\'"
54
- end
55
- end.join(" #{fill} ")
1
+ class String
2
+ def to_classname
3
+ if self[0] =='$'
4
+ self[1..-1]
5
+ else
6
+ self.camelize
56
7
  end
57
8
  end
9
+ def to_orient
10
+ self.gsub /%/, '(percent)'
58
11
 
59
-
60
- class MatchConnection
61
- attr_accessor :as
62
- def initialize edge: nil, direction: :both, as: nil, count: 1
63
- @edge = edge
64
- @direction = direction # may be :both, :in, :out
65
- @as = as
66
- @count = count
67
- end
68
-
69
- def direction= dir
70
- @direction = dir
71
- end
72
-
73
-
74
- def direction
75
- fillup = @edge.present? ? @edge : ''
76
- case @direction
77
- when :both
78
- " -#{fillup}- "
79
- when :in
80
- " <-#{fillup}- "
81
- when :out
82
- " -#{fillup}-> "
83
- end
84
-
12
+ end
13
+ def rid?
14
+ self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/
15
+ end
16
+ def from_orient
17
+ if rid?
18
+ ActiveOrient::Model.autoload_object self
19
+ else
20
+ self
21
+ end
85
22
  end
23
+ ## this enables the universal use of an rid-string as pseudonym for a ActiveOrient::Model
24
+ alias :reload! from_orient
25
+ end
26
+ class NilClass
27
+ def to_orient
28
+ self
29
+ end
30
+ end
31
+ class Symbol
32
+ def to_orient
33
+ self.to_s.to_orient
34
+ end
35
+ def from_orient
36
+ self
37
+ end
38
+ end
86
39
 
87
- def compose
88
- ministatement = @as.present? ? "{ as: #{@as} } " : ""
89
- (1 .. @count).map{|x| direction }.join("{}") << ministatement
40
+ class Numeric
41
+ def from_orient
42
+ self
43
+ end
44
+ def to_orient
45
+ self
46
+ end
47
+ end
90
48
 
91
- end
92
-
49
+ class Time
50
+ def from_orient
51
+ self
93
52
  end
53
+ def to_orient
54
+ self
55
+ end
56
+ end
57
+ class Date
58
+ def from_orient
59
+ self
60
+ end
61
+ def to_orient
62
+ self
63
+ end
64
+ end
94
65
 
95
- class MatchStatement
96
- include Support
97
- attr_accessor :as
98
- attr_accessor :where
99
- def initialize match_class=nil, **args
100
- @misc = []
101
- @where = []
102
- @while = []
103
- @maxdepth = 0
104
- @as = nil
105
-
106
-
107
- @match_class = match_class
108
- @as = match_class.pluralize if match_class.is_a? String
109
-
110
- args.each do |k, v|
111
- case k
112
- when :as
113
- @as = v
114
- when :while
115
- @while << v
116
- when :where
117
- @where << v
118
- when :class
119
- @match_class = v
120
- @as = v.pluralize
121
- else
122
- self.send k, v
123
- end
124
- end
125
- end
126
-
127
- def while_s
128
- compose_where( @while ).gsub( /where/, 'while:(' )<< ")" unless @while.blank?
129
- end
66
+ class TrueClass
67
+ def from_orient
68
+ self
69
+ end
70
+ def to_orient
71
+ self
72
+ end
73
+ end
74
+ class FalseClass
75
+ def from_orient
76
+ self
77
+ end
78
+ def to_orient
79
+ self
80
+ end
81
+ end
130
82
 
131
- def match_alias
132
- "as: #{@as }"
83
+ class Array
84
+ def to_orient
85
+ map &:to_orient
133
86
  end
134
- def where_s
135
- compose_where( @where ).gsub( /where/, 'where:(' )<< ")" unless @where.blank?
136
- end
137
-
138
- def maxdepth=x
139
- @maxdepth = x
140
- end
141
-
142
- def method_missing method, *arg, &b
143
- @misc << method.to_s << " " << arg.map(&:to_s).join(' ')
87
+ def from_orient
88
+ map &:from_orient
144
89
  end
90
+ end
91
+ class Hash #WithIndifferentAccess
92
+ def from_orient
93
+ substitute_hash = HashWithIndifferentAccess.new
94
+ keys.each{ |k| puts self[k].inspect }
95
+ keys.each{| k | substitute_hash[k] = self[k].from_orient }
96
+ substitute_hash
145
97
 
146
- def misc
147
- @misc.join(' ') unless @misc.empty?
148
- end
149
- # used for the first compose-statement of a compose-query
150
- def compose_simple
151
- '{'+ [ "class: #{@match_class}",
152
- "as: #{@as}" ,
153
- where_s ].compact.join(', ') + '}'
154
- end
98
+ end
99
+ def to_orient
100
+ substitute_hash = Hash.new
101
+ keys.each{| k | substitute_hash[k] = self[k].to_orient }
102
+ substitute_hash
155
103
 
156
- def compose
104
+ end
157
105
 
158
- '{'+ [ "class: #{@match_class}",
159
- "as: #{@as}" ,
160
- where_s,
161
- while_s,
162
- @maxdepth >0 ? "maxdepth: #{maxdepth}": nil ].compact.join(', ')+'}'
106
+ def nested_under_indifferent_access
107
+ HashWithIndifferentAccess.new self
163
108
  end
164
- alias :to_s :compose
165
109
  end
166
110
 
167
- class OrientQuery
168
- include Support
169
111
 
170
- =begin
171
- Call where without a parameter to request the saved where-string
172
- To create the where-part of the query a string, a hash or an Array is supported
112
+ module OrientSupport
173
113
 
174
- where: "r > 9" --> where r > 9
175
- where: {a: 9, b: 's'} --> where a = 9 and b = 's'
176
- where:[{ a: 2} , 'b > 3',{ c: 'ufz' }] --> where a = 2 and b > 3 and c = 'ufz'
177
- =end
114
+ module Support
115
+ =begin
116
+ supports
178
117
 
179
- attr_accessor :where
180
- attr_accessor :let
181
- attr_accessor :projection
182
- attr_accessor :order
183
- attr_accessor :match_statements
184
-
185
- def initialize **args
186
- @projection = []
187
- @misc = []
188
- @let = []
189
- @where = []
190
- @order = []
191
- @aliases = []
192
- @match_statements = []
193
- @class = nil
194
- @kind = 'select'
195
- args.each do |k, v|
196
- case k
197
- when :projection
198
- @projection << v
199
- when :let
200
- @let << v
201
- when :order
202
- @order << v
203
- when :where
204
- @where << v
205
- when :kind
206
- @kind = v
207
- when :start
208
- @match_statements[0] = MatchStatement.new **v
209
- # @match_statements[1] = MatchConnection.new
210
- when :connection
211
- @match_statements[1] = MatchConnection.new **v
212
- when :return
213
- @aliases << v
214
- else
215
- self.send k, v
216
- end
217
- end
218
- end
118
+ where: 'string'
119
+ where: { property: 'value', property: value, ... }
120
+ where: ['string, { property: value, ... }, ... ]
219
121
 
220
- def method_missing method, *arg, &b
221
- @misc << method.to_s << " " << arg.map(&:to_s).join(' ')
222
- end
223
122
 
224
- def misc
225
- @misc.join(' ') unless @misc.empty?
226
- end
123
+ Used by update and select
124
+ =end
227
125
 
228
- def subquery
229
- nil
126
+ def compose_where *arg
127
+ arg=arg.flatten
128
+ return "" if arg.blank? || arg.size == 1 && arg.first.blank?
129
+ "where " + arg.map do |issue|
130
+ case issue
131
+ when String
132
+ issue
133
+ when Hash
134
+ generate_sql_list issue
135
+ end
136
+ end.join( ' and ' )
137
+ end
138
+ def generate_sql_list attributes={}
139
+ attributes.map do | key, value |
140
+ case value
141
+ when Numeric
142
+ key.to_s << " = " << value.to_s
143
+ else # String, Symbol, Date, Time, Trueclass, Falseclass ...
144
+ key.to_s << ' = ' << "\'#{ value }\'"
145
+ end
146
+ end.join( ' and ' )
230
147
  end
148
+ end # module
231
149
 
232
150
 
151
+ class OrientQuery
233
152
 
234
- =begin
235
- (only if kind == :match): connect
236
-
237
- Add a connection to the match-query
238
-
239
- A Match-Query alwas has an Entry-Stratement and maybe other Statements.
240
- They are connected via " -> " (outE), "<-" (inE) or "--" (both).
241
-
242
- The connection method adds a connection to the statement-stack.
153
+ include Support
243
154
 
244
- Parameters:
245
- direction: :in, :out, :both
246
- edge_class: to restrict the Query on a certain Edge-Class
247
- count: To repeat the connection
248
- as: Includes a micro-statement to finalize the Match-Query
249
- as: defines a output-variablet, which is used later in the return-statement
155
+ def initialize **args
156
+ @projection = []
157
+ @misc = []
158
+ @let = []
159
+ @where = []
160
+ @order = []
161
+ @kind = 'select'
162
+ args.each do | k,v|
163
+ case k
164
+ when :projection
165
+ @projection << v
166
+ when :let
167
+ @let << v
168
+ when :order
169
+ @order << v
170
+ when :where
171
+ @where << v
172
+ when :kind
173
+ @kind = v
174
+ else
175
+ self.send k, v
176
+ end
177
+ end
178
+ end
250
179
 
251
- The method returns the OrientSupport::MatchConnection object, which can be modified further.
252
- It is compiled by calling compose
253
- =end
180
+ def method_missing method, *arg, &b
181
+ @misc << method.to_s << " " << arg.map(&:to_s).join(' ')
182
+ end
254
183
 
255
- def connect direction, edge_class: nil, count: 1, as: nil
256
- direction= :both unless [ :in, :out].include? direction
257
- match_statements << m = OrientSupport::MatchConnection.new( direction: direction, count: count, as: as)
258
- m
259
- end
184
+ def misc
185
+ @misc.join(' ') unless @misc.empty?
186
+ end
260
187
 
188
+ def subquery
189
+ nil
190
+ end
261
191
  =begin
262
- (only if kind == :match): statement
263
-
264
- A Match Query consists of a simple start-statement
265
- ( classname and where-condition ), a connection followd by other Statement-connection-pairs.
266
- It performs a sub-query starting at the given entry-point.
267
-
268
- Statement adds a statement to the statement-stack.
269
- Statement returns the created OrientSupport::MatchStatement-record for further modifications.
270
- It is compiled by calling »compose«.
271
-
272
- OrientSupport::OrientQuery collects any "as"-directive for inclusion in the return-statement
273
-
274
- Parameter (all optional)
275
- Class: classname, :where: {}, while: {}, as: string, maxdepth: >0 ,
276
-
192
+ Output the compiled query
193
+ parmeter: destination (rest, batch )
194
+ If the query is submitted via the REST-Interface (as get-command), the limit parameter is extracted.
277
195
  =end
278
- def statement match_class= nil, **args
279
- match_statements << s = OrientSupport::MatchStatement.new( mattch_class, args )
280
- s
281
- end
196
+ def compose( destination: :batch )
197
+ if destination == :rest
198
+ [ @kind, projection_s, from, let_s, where_s , subquery, misc, order_s , group_by, unwind, skip ].compact.join(' ')
199
+ else
200
+ [ @kind, projection_s, from, let_s, where_s , subquery, misc, order_s , group_by, limit, unwind, skip ].compact.join(' ')
201
+ end
202
+ end
203
+ alias :to_s :compose
282
204
  =begin
283
- Output the compiled query
284
- Parameter: destination (rest, batch )
285
- If the query is submitted via the REST-Interface (as get-command), the limit parameter is extracted.
205
+ from can either be a Databaseclass to operate on or a Subquery providing data to query further
286
206
  =end
287
-
288
- def compose(destination: :batch)
289
- if @kind == :match
290
- unless @match_statements.empty?
291
- match_query = @kind.to_s.upcase + " "+ @match_statements[0].compose_simple
292
- match_query << @match_statements[1..-1].map( &:compose ).join
293
- match_query << " RETURN "<< (@match_statements.map( &:as ).compact | @aliases).join(', ')
207
+ def from arg=nil
208
+ if arg.present?
209
+ @database = case arg
210
+ when Class
211
+ arg.new.classname
212
+ when ActiveOrient::Model
213
+ classname
214
+ when String
215
+ arg
216
+ when Symbol
217
+ arg
218
+ when OrientQuery
219
+ ' ( '+ arg.to_s + ' ) '
220
+ end
221
+ compose # return the complete query
222
+ else # read from
223
+ "from " << @database.to_s unless @database.nil?
224
+ end
225
+ end
226
+ alias :from= :from
227
+ def database_class= arg
228
+ @database = arg if @database.present?
229
+ if @from.is_a? OrientQuery
230
+ @from.database_class= arg
231
+ end
232
+ end
233
+ def database_class
234
+ if @database.present?
235
+ @database
236
+ elsif @from.is_a? OrientQuery
237
+ @from.database_class
238
+ else
239
+ nil
294
240
  end
295
- elsif destination == :rest
296
- [@kind, projection_s, from, let_s, where_s, subquery, misc, order_s, group_by, unwind, skip].compact.join(' ')
297
- else
298
- [@kind, projection_s, from, let_s, where_s, subquery, misc, order_s, group_by, limit, unwind, skip].compact.join(' ')
299
241
  end
300
- end
301
- alias :to_s :compose
242
+
302
243
 
303
244
  =begin
304
- from can either be a Databaseclass to operate on or a Subquery providing data to query further
305
- =end
245
+ Call where without a parameter to request the saved where-string
306
246
 
247
+ to create the where-part of the query a string, a hash or an Array is supported
307
248
 
308
- def from arg = nil
309
- if arg.present?
310
- @database = case arg
311
- when ActiveOrient::Model # a single record
312
- arg.rrid
313
- when OrientQuery # result of a query
314
- ' ( '+ arg.to_s + ' ) '
315
- when Class
316
- arg.ref_name
317
- else
318
- if arg.to_s.rid? # a string with "#ab:cd"
319
- arg
320
- else # a databas-class-name
321
- arg.to_s
322
- end
323
- end
324
- compose # return the complete query
325
- else # read from
326
- "from #{@database}" unless @database.nil?
249
+ where: "r > 9" --> where r > 9
250
+ where: {a: 9, b: 's'} --> where a = 9 and b = 's'
251
+ where:[{ a: 2} , 'b > 3',{ c: 'ufz' }] --> where a = 2 and b > 3 and c = 'ufz'
252
+ =end
253
+ attr_accessor :where
254
+ def where_s
255
+ compose_where @where
327
256
  end
328
- end
329
- alias :from= :from
330
-
331
- def database_class
332
- if @database.present?
333
- @database
334
- elsif @from.is_a? OrientQuery
335
- @from.database_class
336
- else
337
- nil
338
- end
339
- end
340
257
 
341
- def database_class= arg
342
- @database = arg if @database.present?
343
- if @from.is_a? OrientQuery
344
- @from.database_class= arg
345
- end
346
- end
347
258
 
348
- def where_s
349
- compose_where @where
350
- end
351
-
352
- def let_s
353
- unless @let.empty?
354
- "let " << @let.map do |s|
355
- case s
356
- when String
357
- s
358
- when Array
359
- s.join(', ')
360
- # when Hash ### is not recognized in jruby
361
- else
362
- s.map{|x,y| "$#{x} = (#{y})"}.join(', ')
363
- end
364
- end.join(', ')
365
- end
366
- end
259
+ attr_accessor :let
260
+ def let_s
261
+ unless @let.empty?
262
+ "let " << @let.map do |s|
263
+ case s
264
+ when Hash
265
+ s.map{ |x,y| "$#{x} = ( #{y} )"}.join( ', ')
266
+ when Array
267
+ s.join(', ')
268
+ else
269
+ s
270
+ end
271
+ end.join(', ')
272
+ end
273
+ end
367
274
 
368
- def distinct d
369
- @projection << case d
370
- when String, Symbol
371
- "distinct( #{d.to_s} )"
372
- else
373
- dd= d.to_a.flatten
374
- "distinct( #{dd.first.to_s} ) as #{dd.last}"
375
- end
376
- compose # return the hole query
377
- end
378
- alias :distinct= :distinct
379
-
380
- def projection_s
381
- @projection.map do | s |
382
- case s
383
- when Array
384
- s.join(', ')
385
- when String, Symbol
386
- s.to_s
387
- else
388
- s.map{ |x,y| "#{x} as #{y}"}.join( ', ')
389
- end
390
- end.join( ', ' )
391
- end
275
+ def distinct d
276
+ @projection << case d
277
+ when String, Symbol
278
+ "distinct( #{d.to_s} )"
279
+ when Array
280
+ "distinct( #{d.first} ) as #{d.last}"
281
+ when Hash
282
+ "distinct( #{d.first.first} ) as #{d.first.last}"
283
+ else
284
+ ""
285
+ end
286
+ compose # return the hole query
287
+ end
288
+ alias :distinct= :distinct
289
+
290
+ attr_accessor :projection
291
+ def projection_s
292
+
293
+ @projection.map do | s |
294
+ case s
295
+ when Hash
296
+ s.map{ |x,y| "#{x} as #{y}"}.join( ', ')
297
+ when Array
298
+ s.join(', ')
299
+ else
300
+ s
301
+ end
302
+ end.join( ', ' )
392
303
 
393
- def limit l=nil
394
- @limit = "limit #{l.to_s}" if l.present?
395
- # only a string is allowed
396
- @limit # return_value
397
- end
398
- alias :limit= :limit
304
+ end
399
305
 
400
- def get_limit
401
- @limit.nil? ? -1 : @limit.split(' ').last.to_i
402
- end
403
306
 
404
- def group_by g = nil
405
- @group = "group by #{g.to_s}" if g.present?
406
- # only a string is allowed
407
- @group # return_value
408
- end
307
+ # def where= w
409
308
 
410
- def unwind u = nil
411
- @unwind = "unwind #{u.to_s}" if u.present?
412
- # only a string is allowed
413
- @unwind # return_value
414
- end
309
+ # end
310
+ # select_string = ("select " + select_string + distinct_string + ' from ' + class_name(o_class) ).squeeze(' ')
311
+ # where_string = compose_where( where )
415
312
 
416
- def skip n = nil
417
- @skip = n if n.present?
418
- "skip #{@skip}" if @skip.present?
419
- end
313
+ def limit l=nil
314
+ @limit = "limit #{l.to_s}" if l.present?
315
+ # only a string is allowed
316
+ @limit # return_value
317
+ end
318
+ alias :limit= :limit
319
+ =begin :nodoc
320
+ The Rest-Interface needs to separate the limit-value.
321
+ This Method extracts the number, usage in REST::get_documents
420
322
 
421
- def order_s
422
- unless @order.empty?
423
- # the [@order] is nessesary to enable query.order= "..." oder query.order= { a: :b }
424
- "order by " << [@order].flatten.map do |o|
425
- case o
426
- when String, Symbol, Array
427
- o.to_s
428
- else
429
- o.map{|x,y| "#{x} #{y}"}.join(" ")
430
- end # case
431
- end.join(', ')
432
- else
433
- ''
434
- end # unless
435
- end # def
436
- end # class
323
+ =end
324
+ def get_limit
325
+ @limit.nil? ? -1 : @limit.split(' ').last.to_i
326
+ end
327
+ def group_by g=nil
328
+ @group = "group by #{g.to_s}" if g.present?
329
+ # only a string is allowed
330
+ @group # return_value
331
+ end
332
+ def unwind u=nil
333
+ @unwind = "unwind #{u.to_s}" if u.present?
334
+ # only a string is allowed
335
+ @unwind # return_value
336
+ end
437
337
 
338
+ def skip n=nil
339
+ @skip= n if n.present?
340
+ "skip #{@skip}" if @skip.present?
341
+ end
438
342
 
439
- end # module
343
+ attr_accessor :order
344
+
345
+ def order_s
346
+ unless @order.empty?
347
+ # the [@order] is nessesary to enable query.order= "..." oder query.order= { a: :b }
348
+ "order by " << [@order].flatten.map do | o |
349
+ case o
350
+ when Hash
351
+ o.map{ |x,y| "#{x} #{y}" }.join( " " )
352
+ else
353
+ o.to_s
354
+ end # case
355
+ end.join(', ')
356
+ else
357
+ ''
358
+ end
359
+ end
360
+ # misc_string = if skip > 0 && limit > 0
361
+ # " skip: #{skip} "
362
+ # else
363
+ # ""
364
+ # end
365
+ # #
366
+ #
367
+ # def compose
368
+ #
369
+ # end
370
+
371
+ end
372
+ end # module