hierarchical_db 0.1.8 → 0.1.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f7c6a0c377dd9cdbac0f86ffce7156ee192b729
4
- data.tar.gz: 47656c44af51dad752cf3bed95e1b7e1ec0d0167
3
+ metadata.gz: 7b2796cb616892b387ebbbb7ae58211230224bfc
4
+ data.tar.gz: fc46853d3112e71aac4387ac1221dc575d1ddfee
5
5
  SHA512:
6
- metadata.gz: 0ed4d6738d32c8a88aac196f59641d00c81ca76588e374a0d617fb62448726908a25d58595046dcde492d83731d5c3609ac21ca328aeacb7a2a941c44326d5a5
7
- data.tar.gz: 399082663d6a8861934b149819be95e66eb557eb3c6f10c0940d94780f2117f5f01458cad4728886ef15f20249143590fde27b05b3a25bf41740da0e8e753aa3
6
+ metadata.gz: 0d195077f7ca6a2d049df8f33d0c5bfea2f8695e888d9f157d1ee0e3ab428a1d741188c1e3173ac4c2a06525c4dec6b39aa6048a0aae7d751ec008cdfa0aab51
7
+ data.tar.gz: ad9334f25f375ed9c03348ff4c464a9bb014fb6807ce45209cf29382079dd7a31579bbd5f0abfa6aee57bf2725762a1d0187e005e517791e073d8b96a146787c
@@ -5,7 +5,7 @@ require 'hierarchical_db/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "hierarchical_db"
8
- spec.version = "0.1.8"
8
+ spec.version = "0.1.9"
9
9
  spec.authors = ["Gustavo"]
10
10
  spec.email = ["ginzunza@rebuss.cl"]
11
11
 
@@ -69,27 +69,25 @@ module HierarchicalDb extend ActiveSupport::Concern
69
69
  unless last_brother.empty?
70
70
  last_brother = last_brother[0]
71
71
  previous_right = last_brother.rgt
72
- childs = self.class.where("lft > ?", previous_right)
73
- childs.each do |t|
74
- t.lft = t.lft + 2
75
- t.save
76
- end
77
- childs = self.class.where("rgt > ?", previous_right)
78
- childs.each do |t|
79
- t.rgt = t.rgt + 2
80
- t.save
81
- end
82
72
  #case hasn't brothers
83
73
  else
84
74
  previous_right = father.rgt
85
75
  end
76
+ childs = self.class.where("lft > ?", previous_right)
77
+ childs.each do |t|
78
+ t.lft = t.lft + 2
79
+ t.save
80
+ end
81
+ childs = self.class.where("rgt > ?", previous_right)
82
+ childs.each do |t|
83
+ t.rgt = t.rgt + 2
84
+ t.save
85
+ end
86
86
  #case it is root
87
87
  else
88
88
  last_brother = self.class.where(:rgt => self.class.maximum(:rgt))
89
- unless last_brother.empty?
90
- last_brother = last_brother[0]
91
- previous_right = last_brother.rgt
92
- end
89
+ last_brother = last_brother[0]
90
+ previous_right = last_brother.rgt
93
91
  end
94
92
  self.lft = previous_right + 1
95
93
  self.rgt = previous_right + 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierarchical_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo