simple_nested_set 0.0.25 → 0.0.26

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.
@@ -71,7 +71,7 @@ module SimpleNestedSet
71
71
  nested_set_class.move_after_save = false
72
72
  self.transaction do
73
73
  yield self
74
- # nested_set_class.new(self).rebuild_by_parents!
74
+ # nested_set_class.new(self).rebuild_by_parents!(sort_order)
75
75
  Rebuild::FromParents.new.run(self, sort_order)
76
76
  end
77
77
  ensure
@@ -1,6 +1,7 @@
1
1
  require 'gem_patching'
2
2
 
3
- if Arel::VERSION == '1.0.1'
3
+ case Arel::VERSION
4
+ when '1.0.1'
4
5
  Gem.patching('arel', '1.0.1') do
5
6
  # Arel 1.0.0.rc1 Arel::Table#initialize and #table_exists? does not support
6
7
  # instantiating an Arel::Table before the database table has been created.
@@ -66,10 +67,10 @@ if Arel::VERSION == '1.0.1'
66
67
  end
67
68
  end
68
69
  end
69
- else
70
+ when '2.0.4'
70
71
  Gem.patching('arel', '2.0.4') do
71
72
  Arel::Table.class_eval do
72
- attr_reader :options
73
+ attr_reader :options # this line is added
73
74
 
74
75
  def initialize name, engine = Arel::Table.engine
75
76
  @name = name.to_s
@@ -80,7 +81,7 @@ else
80
81
  @primary_key = nil
81
82
 
82
83
  if Hash === engine
83
- @options = engine
84
+ @options = engine # this line is added
84
85
  @engine = engine[:engine] || Arel::Table.engine
85
86
  @columns = attributes_for engine[:columns]
86
87
 
@@ -91,6 +92,42 @@ else
91
92
  end
92
93
  end
93
94
 
95
+ # this whole method is added
96
+ def as(table_alias)
97
+ @options ||= {}
98
+ Arel::Table.new(name, options.merge(:as => table_alias))
99
+ end
100
+ end
101
+ end
102
+ else # include the latest patch here, if any
103
+ # this patch is equivalent to the 2.0.4 one, it is only listed here, because
104
+ # it is the latest version. The when-statements should be merge, once a new
105
+ # version comes
106
+ Gem.patching('arel', '2.0.5') do
107
+ Arel::Table.class_eval do
108
+ attr_reader :options # this line is added
109
+
110
+ def initialize name, engine = Arel::Table.engine
111
+ @name = name.to_s
112
+ @engine = engine
113
+ @columns = nil
114
+ @aliases = []
115
+ @table_alias = nil
116
+ @primary_key = nil
117
+
118
+ if Hash === engine
119
+ @options = engine # this line is added
120
+ @engine = engine[:engine] || Arel::Table.engine
121
+ @columns = attributes_for engine[:columns]
122
+
123
+ # Sometime AR sends an :as parameter to table, to let the table know
124
+ # that it is an Alias. We may want to override new, and return a
125
+ # TableAlias node?
126
+ @table_alias = engine[:as] unless engine[:as].to_s == @name
127
+ end
128
+ end
129
+
130
+ # this whole method is added
94
131
  def as(table_alias)
95
132
  @options ||= {}
96
133
  Arel::Table.new(name, options.merge(:as => table_alias))
@@ -1,3 +1,3 @@
1
1
  module SimpleNestedSet
2
- VERSION = "0.0.25"
2
+ VERSION = "0.0.26"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 25
10
- version: 0.0.25
9
+ - 26
10
+ version: 0.0.26
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-29 00:00:00 +01:00
18
+ date: 2010-12-01 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency