Class: ActiveRecord::Fixture
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveRecord::Fixture
 
 
- Includes:
 - Enumerable
 
- Defined in:
 - lib/active_record/fixtures.rb
 
Overview
:nodoc:
Defined Under Namespace
Classes: FixtureError, FormatError
Instance Attribute Summary collapse
- 
  
    
      #fixture  ⇒ Object 
    
    
      (also: #to_hash)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute fixture.
 - 
  
    
      #model_class  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute model_class.
 
Instance Method Summary collapse
- #[](key) ⇒ Object
 - #class_name ⇒ Object
 - #each ⇒ Object
 - #find ⇒ Object
 - 
  
    
      #initialize(fixture, model_class)  ⇒ Fixture 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Fixture.
 
Constructor Details
#initialize(fixture, model_class) ⇒ Fixture
Returns a new instance of Fixture.
      709 710 711 712  | 
    
      # File 'lib/active_record/fixtures.rb', line 709 def initialize(fixture, model_class) @fixture = fixture @model_class = model_class end  | 
  
Instance Attribute Details
#fixture ⇒ Object (readonly) Also known as: to_hash
Returns the value of attribute fixture.
      707 708 709  | 
    
      # File 'lib/active_record/fixtures.rb', line 707 def fixture @fixture end  | 
  
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
      707 708 709  | 
    
      # File 'lib/active_record/fixtures.rb', line 707 def model_class @model_class end  | 
  
Instance Method Details
#[](key) ⇒ Object
      722 723 724  | 
    
      # File 'lib/active_record/fixtures.rb', line 722 def [](key) fixture[key] end  | 
  
#class_name ⇒ Object
      714 715 716  | 
    
      # File 'lib/active_record/fixtures.rb', line 714 def class_name model_class.name if model_class end  | 
  
#each ⇒ Object
      718 719 720  | 
    
      # File 'lib/active_record/fixtures.rb', line 718 def each fixture.each { |item| yield item } end  | 
  
#find ⇒ Object
      728 729 730 731 732 733  | 
    
      # File 'lib/active_record/fixtures.rb', line 728 def find raise FixtureClassNotFound, "No class attached to find." unless model_class model_class.unscoped do model_class.find(fixture[model_class.primary_key]) end end  |