Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8499

Show
Ignore:
Timestamp:
12/28/07 05:42:12 (8 months ago)
Author:
bitsweat
Message:

Ruby 1.9 compat: introduce instance_variable_names. Closes #10630 [Frederick Cheung]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/lib/action_mailer/adv_attr_accessor.rb

    r4310 r8499  
    1717            raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1 
    1818            if parameters.empty? 
    19               if instance_variables.include?(ivar) 
     19              if instance_variable_names.include?(ivar) 
    2020                instance_variable_get(ivar) 
    2121              end 
  • trunk/actionpack/lib/action_controller/base.rb

    r8374 r8499  
    12111211      def add_instance_variables_to_assigns 
    12121212        @@protected_variables_cache ||= Set.new(protected_instance_variables) 
    1213         instance_variables.each do |var| 
     1213        instance_variable_names.each do |var| 
    12141214          next if @@protected_variables_cache.include?(var) 
    12151215          @assigns[var[1..-1]] = instance_variable_get(var) 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r8318 r8499  
    374374      # understandable error message. 
    375375      %w(@controller @request @response).each do |iv_name| 
    376         if !(instance_variables.include?(iv_name) || instance_variables.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil? 
     376        if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil? 
    377377          raise "#{iv_name} is nil: make sure you set it in your test's setup method." 
    378378        end 
  • trunk/actionpack/test/controller/new_render_test.rb

    r8372 r8499  
    496496 
    497497    get :hello_world 
     498    assert !assigns.include?('_request'), '_request should not be in assigns' 
    498499    assert !assigns.include?('request'), 'request should not be in assigns' 
    499500 
  • trunk/activerecord/test/associations/inner_join_association_test.rb

    r8126 r8499  
    6868    authors = Author.find(:all, :select => 'authors.*', :joins => :posts) 
    6969    assert !authors.empty?, "expected authors to be non-empty" 
    70     assert authors.all? {|a| !a.send(:instance_variables).include?("@posts")}, "expected no authors to have the @posts association loaded" 
     70    assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded" 
    7171  end 
    7272   
  • trunk/activesupport/lib/active_support/core_ext/object/instance_variables.rb

    r7654 r8499  
    1414  end 
    1515 
     16  def instance_variable_names 
     17    instance_variables.map(&:to_s) 
     18  end 
     19 
    1620  def copy_instance_variables_from(object, exclude = []) #:nodoc: 
    1721    exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables 
  • trunk/activesupport/test/core_ext/object_and_class_ext_test.rb

    r7658 r8499  
    183183  end 
    184184 
     185  def test_instance_variable_names 
     186    assert_equal %w(@bar @baz), @source.instance_variable_names.sort 
     187  end 
     188 
    185189  def test_instance_variable_defined 
    186190    assert @source.instance_variable_defined?('@bar')