simple_nested_set 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -73,10 +73,26 @@ when /^2\.0\.[5-9]$/, /^2\.1\.[01]$/, '2.0.10'
73
73
  attr_reader :options # this line is added
74
74
 
75
75
  def initialize name, engine = Arel::Table.engine
76
- @options = engine if Hash === engine
77
- super name, engine
76
+ @name = name.to_s
77
+ @engine = engine
78
+ @columns = nil
79
+ @aliases = []
80
+ @table_alias = nil
81
+ @primary_key = nil
82
+
83
+ if Hash === engine
84
+ @options = engine # this line has been added
85
+ @engine = engine[:engine] || Arel::Table.engine
86
+ @columns = attributes_for engine[:columns]
87
+
88
+ # Sometime AR sends an :as parameter to table, to let the table know
89
+ # that it is an Alias. We may want to override new, and return a
90
+ # TableAlias node?
91
+ @table_alias = engine[:as] unless engine[:as].to_s == @name
92
+ end
78
93
  end
79
94
 
95
+ # this whole method is new
80
96
  def as(table_alias)
81
97
  @options ||= {}
82
98
  Arel::Table.new(name, options.merge(:as => table_alias))
@@ -1,3 +1,3 @@
1
1
  module SimpleNestedSet
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs