Skip to content

Commit

Permalink
Don't require an explicit call to init_reactor when extending
Browse files Browse the repository at this point in the history
  • Loading branch information
tjkirch committed Mar 13, 2011
1 parent 376e8db commit 685f9e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion events/admin.rb
Expand Up @@ -899,7 +899,6 @@ def areaction(event, player, room)
elsif not object.is_a? Reacts and (event[:command] == "load" or event[:command] == "reload")
player.output "Object cannot react, adding react ability."
object.extend(Reacts)
object.init_reactor
end

case event[:command]
Expand Down
7 changes: 5 additions & 2 deletions traits/reacts.rb
Expand Up @@ -11,8 +11,11 @@ def uses_reaction? file
@reactions_files.include? file
end

#This is called when the object is created, but if the
#module is mixed in dynamically this needs to be called before being used
# Automatically set up the reactor when we extend an object
def self.extended(obj)
obj.init_reactor
end

def init_reactor
@reactor ||= Reactor.new(self)
@reaction_files ||= Set.new
Expand Down

0 comments on commit 685f9e7

Please sign in to comment.