Skip to content

Commit

Permalink
Remove the private function addActionToEvent()
Browse files Browse the repository at this point in the history
The function is no longer necessary now that we have addAction() as
the sole public method for adding actions to events.  Previously we
needed this function to help with addActionWithInterval() but now
that the method is no longer part of the API we simply the code base
by getting rid of this internal function.
  • Loading branch information
Eric James Michael Ritz committed Sep 2, 2013
1 parent 1678ef6 commit ddc4a2e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/Luvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,6 @@ local function findAction(event, actionToFind)
return false, nil
end

--- Add a new action to an event.
--
-- This function is private to Luvent and exists to factor out the
-- common logic in the public API for adding actions to events.
--
-- @see Luvent:addAction
local function addActionToEvent(event, action)
assert(isActionCallable(action) == true)

-- We do not allow adding an action more than once to an event.
if event:callsAction(action) then return end

local new = newAction(action)
table.insert(event.actions, new)
return new.id
end

--- Add an action to an event.
--
-- It is not possible to add the same action more than once.
Expand All @@ -203,7 +186,14 @@ end
--
-- @see isActionCallable
function Luvent:addAction(actionToAdd)
return addActionToEvent(self, actionToAdd)
assert(isActionCallable(actionToAdd) == true)

-- We do not allow adding an action more than once to an event.
if self:callsAction(actionToAdd) then return end

local new = newAction(actionToAdd)
table.insert(self.actions, new)
return new.id
end

--- Remove an action from an event.
Expand Down

0 comments on commit ddc4a2e

Please sign in to comment.