Changeset 6
- Timestamp:
- 08/09/06 17:24:18 (2 years ago)
- Files:
-
- trunk/lib/better_nested_set.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/better_nested_set.rb
r4 r6 59 59 # Usage is to name them 'lft' and 'rgt' for instance. 60 60 # 61 module ClassMethods 61 module ClassMethods 62 62 # Configuration options are: 63 63 # … … 87 87 class_inheritable_reader :acts_as_nested_set_options 88 88 89 attr_accessor acts_as_nested_set_options[:left_column].intern, acts_as_nested_set_options[:right_column].intern 89 # no bulk assignment 90 attr_protected acts_as_nested_set_options[:left_column].intern, 91 acts_as_nested_set_options[:right_column].intern, 92 acts_as_nested_set_options[:parent_column].intern 93 # no assignment to structure fields 94 module_eval <<-"end_eval", __FILE__, __LINE__ 95 def #{acts_as_nested_set_options[:left_column]}=(x) 96 raise ActiveRecord::ActiveRecordError, "Unauthorized assignment to #{acts_as_nested_set_options[:left_column]}: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead." 97 end 98 def #{acts_as_nested_set_options[:right_column]}=(x) 99 raise ActiveRecord::ActiveRecordError, "Unauthorized assignment to #{acts_as_nested_set_options[:right_column]}: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead." 100 end 101 def #{acts_as_nested_set_options[:parent_column]}=(x) 102 raise ActiveRecord::ActiveRecordError, "Unauthorized assignment to #{acts_as_nested_set_options[:parent_column]}: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead." 103 end 104 end_eval 90 105 91 106 include SymetrieCom::Acts::NestedSet::InstanceMethods … … 153 168 154 169 if child.root? 155 raise "Adding sub-tree isn\'t currently supported"170 raise ActiveRecord::ActiveRecordError, "Adding sub-tree isn\'t currently supported" 156 171 else 157 172 if ( (self[acts_as_nested_set_options[:left_column]] == nil) || (self[acts_as_nested_set_options[:right_column]] == nil) ) … … 282 297 protected 283 298 def move_to(target, position) 284 raise ActiveRecord Error, "You cannot move a new node" if self.id.nil?299 raise ActiveRecord::ActiveRecordError, "You cannot move a new node" if self.id.nil? 285 300 286 301 # use shorter names for readability: current left and right … … 298 313 # detect impossible move 299 314 if ((cur_left <= target_left) && (target_left <= cur_right)) or ((cur_left <= target_right) && (target_right <= cur_right)) 300 raise ActiveRecord Error, "Impossible move, target node cannot be inside moved tree."315 raise ActiveRecord::ActiveRecordError, "Impossible move, target node cannot be inside moved tree." 301 316 end 302 317 … … 327 342 end 328 343 else 329 raise ActiveRecord Error, "Position should be either left or right ('#{position}' received)."344 raise ActiveRecord::ActiveRecordError, "Position should be either left or right ('#{position}' received)." 330 345 end 331 346
