1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/sass/script/funcall.rb
2009-04-24 18:09:01 -07:00

29 lines
892 B
Ruby

require File.join(File.dirname(__FILE__), 'functions')
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 Haml::Util.has?(:public_instance_method, Functions, name) && name !~ /^__/
return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
end
return Functions::EvaluationContext.new(environment.options).send(name, *args)
rescue ArgumentError => e
raise e unless e.backtrace.first =~ /:in `(#{name}|perform)'$/
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
end
end
end
end