I'm trying to use a variable t
in a other method, passed in initialize
.
This is my class for Term:
class Term
include AASM
attr_accessor :t
def initialize(term)
@t = term
puts self.t
end
aasm do
state :Initialized, :initial => true
state :OrthographyChecked
event :Orthography do
puts "Check Orthography"
# use @t variable here
transitions :from => :Initialized, :to => :UniquenessChecked
end
# .. more events
end
end
term = Term.new("textstring")
I make a new instance, but the order of the printed texts is not what I expect. I get:
Check Orthography #from Orthography event
textstring #from initialize method
I don't understand why the initialize method is fired last, I want to use variable @t
also in other methods of aasm do events
. How can I do that, without getting @t
being nil
or t method not found
?