mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
28 lines
774 B
Ruby
28 lines
774 B
Ruby
module Sass
|
|
module Script
|
|
class Funcall # :nodoc:
|
|
attr_reader :name, :args
|
|
|
|
def initialize(name, args)
|
|
@name = name
|
|
@args = args
|
|
end
|
|
|
|
def inspect
|
|
"#{name}(#{args.map {|a| a.inspect}.join(', ')})"
|
|
end
|
|
|
|
def perform(environment)
|
|
args = self.args.map {|a| a.perform(environment)}
|
|
unless Functions.public_instance_methods.include?(name) && name !~ /^__/
|
|
return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
|
|
end
|
|
|
|
return Functions.send(name, *args)
|
|
rescue ArgumentError => e
|
|
raise e unless e.backtrace.first =~ /:in `#{name}'$/
|
|
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
|
|
end
|
|
end
|
|
end
|
|
end
|