smql 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/smql_to_ar.rb +33 -15
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/lib/smql_to_ar.rb CHANGED
@@ -43,9 +43,9 @@ class SmqlToAR
43
43
  # Die eigentliche Exception wird in @data[:exception] hinterlegt.
44
44
  class SubSMQLError < SMQLError
45
45
  def initialize query, model, exception
46
- ex = {:class => exception.class, :message => exception.message}
46
+ ex = {class: exception.class, message: exception.message}
47
47
  ex[:data] = exception.data if exception.respond_to? :data
48
- super :query => query, :model => model.to_s, :exception => ex
48
+ super query: query, model: model.to_s, exception: ex
49
49
  set_backtrace exception.backtrace
50
50
  end
51
51
  end
@@ -55,49 +55,49 @@ class SmqlToAR
55
55
  # Malformed ColOp
56
56
  class UnexpectedColOpError < ParseError
57
57
  def initialize model, colop, val
58
- super :got => colop, :val => val, :model => model.to_s
58
+ super got: colop, val: val, model: model.to_s
59
59
  end
60
60
  end
61
61
 
62
62
  class UnexpectedError < ParseError
63
63
  def initialize model, colop, val
64
- super :got => {colop => val}, :model => model.to_s
64
+ super got: {colop => val}, model: model.to_s
65
65
  end
66
66
  end
67
67
 
68
68
  class NonExistingSelectableError < SMQLError
69
69
  def initialize got
70
- super :got => got
70
+ super got: got
71
71
  end
72
72
  end
73
73
 
74
74
  class NonExistingColumnError < SMQLError
75
75
  def initialize expected, got
76
- super :expected => expected, :got => got
76
+ super expected: expected, got: got
77
77
  end
78
78
  end
79
79
 
80
80
  class NonExistingRelationError < SMQLError
81
81
  def initialize expected, got
82
- super :expected => expected, :got => got
82
+ super expected: expected, got: got
83
83
  end
84
84
  end
85
85
 
86
86
  class ProtectedColumnError < SMQLError
87
87
  def initialize protected_column
88
- super :protected_column => protected_column
88
+ super protected_column: protected_column
89
89
  end
90
90
  end
91
91
 
92
92
  class RootOnlyFunctionError < SMQLError
93
93
  def initialize path
94
- super :path => path
94
+ super path: path
95
95
  end
96
96
  end
97
97
 
98
98
  class ConColumnError < SMQLError
99
99
  def initialize expected, got
100
- super :expected => expected, :got => got
100
+ super expected: expected, got: got
101
101
  end
102
102
  end
103
103
 
@@ -243,8 +243,8 @@ class SmqlToAR
243
243
  refls = model.respond_to?( :reflections) && model.reflections
244
244
  refls && refls.each do |name, refl|
245
245
  r[model.name][name] = case refl
246
- when ActiveRecord::Reflection::ThroughReflection then {:macro => refl.macro, :model => refl.klass.name, :through => refl.through_reflection.name}
247
- when ActiveRecord::Reflection::AssociationReflection then {:macro => refl.macro, :model => refl.klass.name}
246
+ when ActiveRecord::Reflection::ThroughReflection then {macro: refl.macro, model: refl.klass.name, through: refl.through_reflection.name}
247
+ when ActiveRecord::Reflection::AssociationReflection then {macro: refl.macro, model: refl.klass.name}
248
248
  else raise "Ups: #{refl.class}"
249
249
  end
250
250
  models.push refl.klass unless r.keys.include? refl.klass.name
@@ -293,8 +293,26 @@ class SmqlToAR
293
293
  lib_dir = File.dirname __FILE__
294
294
  fj = lambda {|*a| File.join lib_dir, *a }
295
295
  Object.send :remove_const, :SmqlToAR
296
- load fj.call( 'smql_to_ar.rb')
297
- load fj.call( 'smql_to_ar', 'condition_types.rb')
298
- load fj.call( 'smql_to_ar', 'query_builder.rb')
296
+ load fj[ 'smql_to_ar.rb']
297
+ load fj[ 'smql_to_ar', 'condition_types.rb']
298
+ load fj[ 'smql_to_ar', 'query_builder.rb']
299
+ end
300
+
301
+ module ActiveRecordExtensions
302
+ def self.included base
303
+ base.extend ClassMethods
304
+ end
305
+
306
+ module ClassMethods
307
+ def smql *params
308
+ SmqlToAR.to_ar self, *params
309
+ end
310
+
311
+ def smql_protected
312
+ []
313
+ end
314
+ end
299
315
  end
300
316
  end
317
+
318
+ ActiveRecord::Base.send :include, SmqlToAR::ActiveRecordExtensions
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Denis Knauf
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-09 00:00:00 +01:00
17
+ date: 2012-07-03 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency