Skip to content

Commit

Permalink
Report an error if the user attempts to shadow a
Browse files Browse the repository at this point in the history
core API fn.
  • Loading branch information
samaaron committed Nov 20, 2014
1 parent d367540 commit c41eaa5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/server/sonicpi/lib/sonicpi/spiderapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ def ndefine(name, &block)

def define(name, &block)
raise "define must be called with a code block" unless block
if @user_methods.method_defined? name
already_defined = @user_methods.method_defined? name

if !already_defined && self.respond_to?(name)
raise "A function called #{name} is already part of Sonic Pi's core API. Please choose another name."
end

if already_defined
__info "Redefining #{name}"
else
__info "Defining #{name}"
Expand Down

0 comments on commit c41eaa5

Please sign in to comment.