Changeset 232

Show
Ignore:
Timestamp:
06/12/05 09:37:25 (3 years ago)
Author:
ged
Message:
  • Fixes #11 -- def_traits now correctly adds methods to the calling class instead of FaerieMUD::ComposedObject? itself.
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/fm/composedobject.rb

    r212 r232  
    200200    # SVN Id 
    201201    SVNId = %q$Id$ 
    202  
    203     # SVN URL 
    204     SVNURL = %q$URL$ 
    205202 
    206203    # The factor which is applied to traits' modifiers in the calculation of 
     
    368365 
    369366        self.traitMap[ name ] = constituents 
    370         eval( self::buildTraitMethods(name, *constituents), nil, __FILE__, __LINE__ ) 
     367        code = self::buildTraitMethods( name, *constituents ) 
     368 
     369        module_eval( code ) 
    371370    end 
    372371 
  • trunk/tests/composedobject.tests.rb

    r212 r232  
    44# $Id$ 
    55# 
    6 # Copyright (c) 2003, 2004 The FaerieMUD Consortium. 
     6# Copyright (c) 2003, 2004, 2005 The FaerieMUD Consortium. 
    77#  
    88 
     
    314314        } 
    315315        assert_respond_to testObj, :trait1, "Does not respond to trait1 accessor" 
     316        assert testClass::instance_methods(false).include?( "trait1" ), 
     317            "Trait method #trait1 should inhere in the subclass" 
    316318        assert_respond_to testObj, :trait2, "Does not respond to trait2 accessor" 
     319        assert testClass::instance_methods(false).include?( "trait2" ), 
     320            "Trait method #trait2 should inhere in the subclass" 
    317321        assert_respond_to testObj, :trait3, "Does not respond to trait3 accessor" 
     322        assert testClass::instance_methods(false).include?( "trait3" ), 
     323            "Trait method #trait3 should inhere in the subclass" 
    318324    end 
    319325 
     
    360366        } 
    361367        assert_respond_to testObj, :trait1_2, "Does not respond to trait1_2 accessor" 
     368        assert testClass::instance_methods(false).include?( "trait1_2" ), 
     369            "Trait method #trait1_2 should inhere in the subclass" 
    362370        assert_respond_to testObj, :trait2_3, "Does not respond to trait2_3 accessor" 
     371        assert testClass::instance_methods(false).include?( "trait2_3" ), 
     372            "Trait method #trait2_3 should inhere in the subclass" 
    363373        assert_respond_to testObj, :trait3_1, "Does not respond to trait3_1 accessor" 
     374        assert testClass::instance_methods(false).include?( "trait3_1" ), 
     375            "Trait method #trait3_1 should inhere in the subclass" 
    364376        assert_respond_to testObj, :trait2_1, "Does not respond to trait2_1 accessor" 
     377        assert testClass::instance_methods(false).include?( "trait2_1" ), 
     378            "Trait method #trait2_1 should inhere in the subclass" 
    365379        assert_respond_to testObj, :trait3_2, "Does not respond to trait3_2 accessor" 
     380        assert testClass::instance_methods(false).include?( "trait3_2" ), 
     381            "Trait method #trait3_2 should inhere in the subclass" 
    366382        assert_respond_to testObj, :trait1_3, "Does not respond to trait1_3 accessor" 
     383        assert testClass::instance_methods(false).include?( "trait1_3" ), 
     384            "Trait method #trait1_3 should inhere in the subclass" 
    367385    end 
    368386 
     
    406424        } 
    407425        assert_respond_to testObj, :trait1_2_3, "Does not respond to trait1_2_3 accessor" 
     426        assert testClass::instance_methods(false).include?( "trait1_2_3" ), 
     427            "Trait method #trait1_2_3 should inhere in the subclass" 
    408428        assert_respond_to testObj, :trait2_3_1, "Does not respond to trait2_3_1 accessor" 
     429        assert testClass::instance_methods(false).include?( "trait2_3_1" ), 
     430            "Trait method #trait2_3_1 should inhere in the subclass" 
    409431        assert_respond_to testObj, :trait3_1_2, "Does not respond to trait3_1_2 accessor" 
     432        assert testClass::instance_methods(false).include?( "trait3_1_2" ), 
     433            "Trait method #trait3_1_2 should inhere in the subclass" 
    410434 
    411435        self.class.addSetupBlock {