Changeset 141

Show
Ignore:
Timestamp:
10/06/06 15:56:43 (2 years ago)
Author:
ahorn
Message:

corex branch: tighten access to @@descendants in page model

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/corex/radiant/app/models/page.rb

    r136 r141  
    7878    Status.find(self.status_id) 
    7979  end 
     80 
    8081  def status=(value) 
    8182    self.status_id = value.id 
     
    150151   
    151152  class << self 
     153 
    152154    def find_by_url(url, live = true) 
    153155      root = find_by_parent_id(nil) 
     
    172174    end 
    173175     
    174     @@descendants = [] 
    175176    def descendants 
    176177      @@descendants.dup 
    177178    end 
    178      
    179     def inherited_with_descendants(subclass) 
    180       inherited_without_descendants(subclass) 
    181       @@descendants << subclass 
    182     end 
    183     alias :inherited_without_descendants :inherited 
    184     alias :inherited :inherited_with_descendants 
     179 
     180    private 
     181 
     182      def add_descendant(subclass) 
     183        @@descendants ||= [] 
     184        @@descendants << subclass 
     185      end 
     186     
     187      def inherited_with_descendants(subclass) 
     188        add_descendant(subclass) 
     189        inherited_without_descendants(subclass) 
     190      end 
     191 
     192      alias :inherited_without_descendants :inherited 
     193      alias :inherited :inherited_with_descendants 
    185194     
    186195  end 
     
    215224  
    216225  private 
    217    
    218     def attributes_protected_by_default 
    219       default = super 
    220       default.delete(self.class.inheritance_column) 
    221       default 
    222     end 
    223   
    224     def update_published_at 
    225       write_attribute('published_at', Time.now) if (status_id.to_i == Status[:published].id) and published_at.nil? 
    226       true 
    227     end 
    228      
    229     def update_virtual 
    230       write_attribute('virtual', virtual?) 
    231       true 
    232     end 
    233      
     226      
    234227    # def update_file_not_found 
    235228    #   write_attribute('file_not_found', file_not_found?) 
     
    264257    end 
    265258 
    266      
     259    def attributes_protected_by_default 
     260      default = super 
     261      default.delete(self.class.inheritance_column) 
     262      default 
     263    end 
     264  
     265    def update_published_at 
     266      write_attribute('published_at', Time.now) if (status_id.to_i == Status[:published].id) and published_at.nil? 
     267      true 
     268    end 
     269     
     270    def update_virtual 
     271      write_attribute('virtual', virtual?) 
     272      true 
     273    end 
     274  
    267275    # 
    268276    # <r:url />