# File lib/better_nested_set.rb, line 74
 74:         def acts_as_nested_set(options = {})          
 75:           if options[:scope].is_a?(Symbol) 
 76:             if options[:scope].to_s !~ /_id$/
 77:               options[:scope] = "#{options[:scope]}_id".intern 
 78:             end          
 79:             options[:scope] = %(#{options[:scope].to_s}.nil? ? "#{options[:scope].to_s} IS NULL" : "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}")
 80:           end
 81: 
 82: #            options[:scope] = %("#{options[:scope]}") 
 83: 
 84:           write_inheritable_attribute(:acts_as_nested_set_options,
 85:              { :parent_column  => (options[:parent_column] || 'parent_id'),
 86:                :left_column    => (options[:left_column]   || 'lft'),
 87:                :right_column   => (options[:right_column]  || 'rgt'),
 88:                :scope          => (options[:scope] || '1 = 1'),
 89:                :text_column    => (options[:text_column] || columns.collect{|c| (c.type == :string) ? c.name : nil }.compact.first)
 90:               } )
 91:                
 92:           class_inheritable_reader :acts_as_nested_set_options
 93:         
 94:           # no bulk assignment
 95:           attr_protected  acts_as_nested_set_options[:left_column].intern,
 96:                           acts_as_nested_set_options[:right_column].intern,
 97:                           acts_as_nested_set_options[:parent_column].intern
 98:           # no assignment to structure fields
 99:           module_eval "def \#{acts_as_nested_set_options[:left_column]}=(x)\nraise 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.\"\nend\ndef \#{acts_as_nested_set_options[:right_column]}=(x)\nraise 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.\"\nend\ndef \#{acts_as_nested_set_options[:parent_column]}=(x)\nraise 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.\"\nend\n", __FILE__, __LINE__
100:         
101:           include SymetrieCom::Acts::NestedSet::InstanceMethods
102:           extend SymetrieCom::Acts::NestedSet::ClassMethods
103:           
104:           # adds the helper for the class
105: #          ActionView::Base.send(:define_method, "#{Inflector.underscore(self.class)}_options_for_select") { special=nil
106: #              "#{acts_as_nested_set_options[:text_column]} || "#{self.class} id #{id}"
107: #            }
108:           
109:         end