Class: SassC::FunctionsHandler
- Inherits:
-
Object
- Object
- SassC::FunctionsHandler
- Defined in:
- lib/sassc/functions_handler.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ FunctionsHandler
constructor
A new instance of FunctionsHandler.
- #setup(_native_options, functions: Script::Functions) ⇒ Object
Constructor Details
#initialize(options) ⇒ FunctionsHandler
Returns a new instance of FunctionsHandler.
5 6 7 |
# File 'lib/sassc/functions_handler.rb', line 5 def initialize() @options = end |
Instance Method Details
#setup(_native_options, functions: Script::Functions) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sassc/functions_handler.rb', line 9 def setup(, functions: Script::Functions) @callbacks = {} functions_wrapper = Class.new do attr_accessor :options include functions end.new functions_wrapper. = @options Script.custom_functions(functions: functions).each do |custom_function| callback = lambda do |native_argument_list| function_arguments = arguments_from_native_list(native_argument_list) begin result = functions_wrapper.send(custom_function, *function_arguments) rescue StandardError raise ::Sass::ScriptError, "Error: error in C function #{custom_function}" end to_native_value(result) rescue StandardError => e warn "[SassC::FunctionsHandler] #{e.cause.}" raise e end @callbacks[Script.formatted_function_name(custom_function, functions: functions)] = callback end @callbacks end |