All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.sass-3.2.8.lib.sass.callbacks.rb Maven / Gradle / Ivy

Go to download

Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It's translated to well-formatted, standard CSS using the command line tool or a web-framework plugin. This is a repackaged GEM in a JAR format of the sass-lang.gem package. The sass-gems package version follows the sass-lang.gem versions located http://rubyforge.org/frs/?group_id=9702. Simply change the version of this package to download and repackage the same GEM version.

There is a newer version: 3.2.9
Show newest version
module Sass
  # A lightweight infrastructure for defining and running callbacks.
  # Callbacks are defined using \{#define\_callback\} at the class level,
  # and called using `run_#{name}` at the instance level.
  #
  # Clients can add callbacks by calling the generated `on_#{name}` method,
  # and passing in a block that's run when the callback is activated.
  #
  # @example Define a callback
  #   class Munger
  #     extend Sass::Callbacks
  #     define_callback :string_munged
  #
  #     def munge(str)
  #       res = str.gsub(/[a-z]/, '\1\1')
  #       run_string_munged str, res
  #       res
  #     end
  #   end
  #
  # @example Use a callback
  #   m = Munger.new
  #   m.on_string_munged {|str, res| puts "#{str} was munged into #{res}!"}
  #   m.munge "bar" #=> bar was munged into bbaarr!
  module Callbacks
    # Automatically includes {InstanceMethods}
    # when something extends this module.
    #
    # @param base [Module]
    def self.extended(base)
      base.send(:include, InstanceMethods)
    end
    protected

    module InstanceMethods
      # Removes all callbacks registered against this object.
      def clear_callbacks!
        @_sass_callbacks = {}
      end
    end

    # Define a callback with the given name.
    # This will define an `on_#{name}` method
    # that registers a block,
    # and a `run_#{name}` method that runs that block
    # (optionall with some arguments).
    #
    # @param name [Symbol] The name of the callback
    # @return [void]
    def define_callback(name)
      class_eval <




© 2015 - 2024 Weber Informatics LLC | Privacy Policy