저는 벽돌 벽을 테스트하여 클래스 재 정의를 테스트하고 있으며, 접근 방법을 모른다. 여기에 내가 테스트하고있어 시나리오 (이 코어 데이터되지는)입니다 :Ruby Motion : 객체 공간에서 Ruby 클래스를 완전히 제거합니다.
- 응용 프로그램은 1 개
- 열망 프로그래머가 실행됩니다 재정의 열을/
- 응용 프로그램을 추가/제거하여 모델을 수정 버전에서 모델 실행 버전 2의 모델
어디에서 문제가 발생하는지는 메모리에서 응용 프로그램을 실제로 제거하고 처음부터 다시 작성하는 것입니다. MotionModel::Model
모듈이 포함되어있을 때 여러 가지 모델 특정 작업이 설정되고 이는 한 번만 발생하기 때문에 중요합니다. 모듈이 클래스에 포함 된 경우.
it "column removal" do
class Removeable
include MotionModel::Model
columns :name => :string, :desc => :string
end
@foo = Removeable.create(:name=> 'Bob', :desc => 'who cares anyway?')
Removeable.serialize_to_file('test.dat')
@foo.should.respond_to :desc
Object.send(:remove_const, :Removeable) # Should remove all traces of Removeable
class Removeable
include MotionModel::model # Should include this again instead
columns :name => :string, # of just reopening the old Removeable
:address => :string # class
end
Removeable.deserialize_from_file # Deserialize old data into new model
Removeable.length.should == 1
@bar = Removeable.first
@bar.should.respond_to :name
@bar.should.respond_to :address
@bar.should.not.respond_to :desc
@bar.name.should == 'Bob'
@bar.address.should == nil
end
end
불행하게도, Object.send(:remove_const, :Removeable)
내가 그것을 것이라고 기대했던 것을하지 않고, 루비 그냥 Removeable
을 다시 열고 MotionModel::Model
모듈의 self.included()
방법을 실행할 수 없습니다 생각 : 여기가 작동 할 수 느꼈다 것입니다.
사양 예제의 컨텍스트에서 처음부터이 클래스의 생성을 에뮬레이션하는 방법에 대한 아이디어가 있습니까?
아마도 멍청한 제안 이었지만 심볼 대신 문자열을 사용해 보았습니까? "이동할 수 있는"? –
'ObjectSend (: remove_const, : Foo)가 정의 되었다면 (Foo)'를 사용하고 있습니다. MotionModel에 대한 저의 커밋에서 문제가 없습니다. 더 이상 문제가되지 않을 수도 있습니다. 아마도 RubyMotion의 캐싱 수정 사항 1.35가이 문제를 해결했을 것입니다. – aceofspades